Abundant, deficient and perfect number classifications: Difference between revisions

No edit summary
Line 440:
 
The sign of the difference is negative for the abundant case - where the sum is greater than the number. And we rely on order being preserved in sequences (this happens to be a fundamental property of computer memory, also).
 
=={{header|Javascript}}==
<lang Javascript>for (var dpa=[1,0,0], n=2; n<=20000; n+=1) {
for (var ds=1, d=2, e=Math.sqrt(n); d<e; d+=1) if (n%d==0) ds+=d+n/d
if (n%e==0) ds+=e
dpa[ds<n ? 0 : ds==n ? 1 : 2]+=1
}
document.write('Deficient:',dpa[0], ', Perfect:',dpa[1], ', Abundant:',dpa[2], '<br>' )</lang>
{{out}}
<pre>Deficient:15043, Perfect:4, Abundant:4953</pre>
 
=={{header|Julia}}==
124

edits