CT091

Amicable Numbers

MediumAcceptance: 0.0%

Let d(n) be the sum of proper divisors of n (numbers less than n that divide into n evenly). If d(a) = b and d(b) = a, where a != b, then a and b are an amicable pair. For example, d(220) = 284 and d(284) = 220, so 220 and 284 are amicable. Given n, evaluate the sum of all amicable numbers below n.

Example 1:

Input: 300
Output: 504

Example 2:

Input: 10000
Output: 31626

Example 3:

Input: 2000
Output: 2898

Constraints:

1 <= n <= 10^5

Tags:

math divisors amicable-numbers
Loading...
Test Cases:No test cases
No test cases available.