Factors of an integer: Difference between revisions
Content added Content deleted
(Lingo added) |
|||
Line 2,292: | Line 2,292: | ||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
<lang lingo>on factors(n) |
<lang lingo>on factors(n) |
||
res = [] |
res = [1] |
||
repeat with i = |
repeat with i = 2 to n/2 |
||
if n mod i = 0 then res.add(i) |
if n mod i = 0 then res.add(i) |
||
end repeat |
end repeat |
||
Line 2,300: | Line 2,300: | ||
end</lang> |
end</lang> |
||
<lang lingo>put factors(45) |
<lang lingo>put factors(45) |
||
-- [1, 3, 5, 9, 15, 45] |
|||
put factors(53) |
|||
-- [1, 53] |
|||
put factors(64) |
|||
-- [1, 2, 4, 8, 16, 32, 64]</lang> |
|||
=={{header|Logo}}== |
=={{header|Logo}}== |