Proper divisors: Difference between revisions

Matlab section
(Promoted to full task status.)
(Matlab section)
Line 2,250:
<pre>{15120, 79}</pre>
 
=={{header|Matlab}}==
<lang matlab>
function D=pd(N)
K=1:ceil(N/2);
D=K(~(rem(N, K)));
</lang>
{{out}}
<pre>
for I=1:10
disp([num2str(I) ' : ' num2str(pd(I))])
end
1 : 1
2 : 1
3 : 1
4 : 1 2
5 : 1
6 : 1 2 3
7 : 1
8 : 1 2 4
9 : 1 3
10 : 1 2 5
 
maxL=0; maxI=0;
for I=1:20000
L=length(pd(I));
if L>maxL
maxL=L; maxI=I;
end
end
maxI
 
maxI =
 
15120
 
maxL
 
maxL =
 
79
</pre>
=={{header|Modula-2}}==
<lang modula2>MODULE ProperDivisors;
Anonymous user