Two numbers are said to be 'amicable' or 'friends' if the sum of the proper divisors of the first is equal to the second, and viceversa. For example, the proper divisors of 220 are: 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 which sum up to 284. 284's proper divisors are 1, 2, 4, 71 and 142, which sum to 220, thus 220 and 284 are friends. Write a function which returns true if and only if a number is a friend of some other number.
Examples:
friend(220) ==> true
friend(7) ==> false
friend(284) ==> true
Function with least number of chars wins.
NOTE: I just found out that there is a similar question, but I believe this one is simpler and perhaps more general.
friend(6)
. As of this writing, the winning solution returnstrue
for 6, but 6 is not actually an amicable number (it's perfect). \$\endgroup\$