n. Add up all of its positive divisors except n itself. Return True if the sum is exactly n, and False otherwise.
A divisor of a number is a positive integer that divides it with no remainder. Trying every number up to n is too slow for n up to 10⁸, so think about how to cut the search down.n=6 → True
The divisors of 6 other than itself are 1, 2 and 3, which add up to 6.
n=12 → False
1 + 2 + 3 + 4 + 6 = 16, not 12.
n=1 → False
1 has no divisors smaller than itself, so the sum is 0.
n=6
True
Run checks the first 3 tests in your browser. Submit checks all 48 tests on the server, hidden ones included.