Aliquot sequence classifications: Difference between revisions

m
→‎{{header|AppleScript}}: Minor improvements to handlers.
m (→‎{{header|Phix}}: class -> classification (for better syntax colouring more than anything else))
m (→‎{{header|AppleScript}}: Minor improvements to handlers.)
Line 171:
 
<lang applescript>on aliquotSum(n)
set sum toif (n >< 12) asthen return integer0
ifset (nsum >to 1) then
set sqrt to n ^ 0.5
repeat with i iffrom (sqrt moddiv 1) isto 0)2 thenby -1
if (n mod i is 0) then set sum to sum + sqrti + n asdiv integeri
end repeat
set sqrt to sqrt - 1
if (nsqrt mod i1.0 is 0.0) then set sum to sum + i +- nsqrt div i1
end if
repeat with i from (sqrt div 1) to 2 by -1
if (n mod i is 0) then set sum to sum + i + n div i
end repeat
end if
return sum
Line 201 ⟶ 197:
if (sequenceLength is 1) then
set classification to "perfect"
else if (sequencen ends withis 0) then
set classification to "terminating"
else if (n = k) then
557

edits