Proper divisors: Difference between revisions

Content added Content deleted
(Undo revision 324745 by Drkameleon (talk))
m (→‎{{header|AppleScript}}: Idiomatic: Minor edit in handler.)
Line 650: Line 650:
if (n > 1) then
if (n > 1) then
set sqrt to n ^ 0.5
set sqrt to n ^ 0.5
if (sqrt mod 1 is 0) then
set limit to sqrt div 1
set end of output to sqrt as integer
if (limit = sqrt) then
set sqrt to sqrt - 1
set end of output to limit
set limit to limit - 1
end if
end if
repeat with i from (sqrt div 1) to 2 by -1
repeat with i from limit to 2 by -1
if (n mod i is 0) then
if (n mod i is 0) then
set beginning of output to i
set beginning of output to i