Amicable pairs
Arturo
<lang rebol>properDivs: function [x] ->
(factors x) -- x
amicable: function [x][
y: sum properDivs x if and? x = sum properDivs y x <> y -> return @[x,y] return ø
]
amicables: []
loop 1..20000 'n [
am: amicable n if am <> ø -> 'amicables ++ @[sort am]
]
print unique amicables</lang>
- Output:
[220 284] [1184 1210] [2620 2924] [5020 5564] [6232 6368] [10744 10856] [12285 14595] [17296 18416]