Amicable pairs

From Rosetta Code
Revision as of 12:33, 19 February 2021 by Drkameleon (talk | contribs) (Replaced content with "=={{header|Arturo}}== <lang rebol>properDivs: function [x] -> (factors x) -- x amicable: function [x][ y: sum properDivs x if and? x = sum properDivs y...")

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]