Practical numbers: Difference between revisions
→{{header|ALGOL 68}}: The proper divisors are unique (apart from root(n)- so no need to check that when adding them...
(Added Algol 68) |
(→{{header|ALGOL 68}}: The proper divisors are unique (apart from root(n)- so no need to check that when adding them...) |
||
Line 84:
INT pd pos := LWB pd - 1;
# returns TRUE if a subset of pd can be summed to n, FALSE otherwise #
PROC can sum to = ( INT x )BOOL:
Line 113 ⟶ 103:
END # can sum to # ;
FOR i FROM 2 TO ENTIER sqrt( n ) DO
IF n MOD i = 0 THEN
INT j = n OVER i;
IF i /= j THEN
FI
OD;
|