RosettaCodeData/Task/Perfect-numbers/MATLAB/perfect-numbers-1.m

10 lines
160 B
Mathematica
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
function perf = isPerfect(n)
total = 0;
for k = 1:n-1
if ~mod(n, k)
total = total+k;
end
end
perf = total == n;
end