Amicable numbers
Problem 21
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
Evaluate the sum of all the amicable numbers under 10000.
| ans = 31626 |
引用大神的代码
本文探讨了数学中有趣的友好数对概念,即两个数彼此的真因数之和恰好等于对方。通过举例220与284这对经典友好数,详细解释了如何寻找并验证友好数对,并提供了计算所有小于10000的友好数对之和的方法。
957

被折叠的 条评论
为什么被折叠?



