Abundant, deficient and perfect number classifications: Difference between revisions
Abundant, deficient and perfect number classifications (view source)
Revision as of 20:33, 5 July 2023
, 10 months ago→{{header|ALGOL 68}}: Simplified - the task doesn't require examples of each type anymore
m (→{{header|K}}) |
(→{{header|ALGOL 68}}: Simplified - the task doesn't require examples of each type anymore) |
||
Line 796:
INT deficient count := 0;
INT perfect count := 0;
INT max number = 20 000;
# construct a table of the proper divisor sums #
Line 809 ⟶ 806:
# classify the numbers #
FOR n TO max number DO
ELIF pd sum = n THEN▼
▲ ELIF pd sum = n
perfect count +:= 1;▼
ELSE # pd sum > n #
abundant count +:= 1;▼
FI
OD;
END
▲ show result( "deficient", deficient count, deficient example );
▲END</syntaxhighlight>
{{out}}
<pre>
abundant 4953
deficient 15043
perfect 4
</pre>
|