Aliquot sequence classifications: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: class -> classification (for better syntax colouring more than anything else)) |
m (→{{header|AppleScript}}: Minor improvements to handlers.) |
||
Line 171: | Line 171: | ||
<lang applescript>on aliquotSum(n) |
<lang applescript>on aliquotSum(n) |
||
if (n < 2) then return 0 |
|||
set sum to 1 |
|||
set sqrt to n ^ 0.5 |
|||
repeat with i from (sqrt div 1) to 2 by -1 |
|||
set sum to sum + |
if (n mod i is 0) then set sum to sum + i + n div i |
||
⚫ | |||
set sqrt to sqrt - 1 |
|||
⚫ | |||
end if |
|||
repeat with i from (sqrt div 1) to 2 by -1 |
|||
⚫ | |||
⚫ | |||
end if |
|||
return sum |
return sum |
||
Line 201: | Line 197: | ||
if (sequenceLength is 1) then |
if (sequenceLength is 1) then |
||
set classification to "perfect" |
set classification to "perfect" |
||
else if ( |
else if (n is 0) then |
||
set classification to "terminating" |
set classification to "terminating" |
||
else if (n = k) then |
else if (n = k) then |