#241 · Math · Beginner · 35 XP · about 7 min
The proper divisors of a number are its divisors other than the number itself. The proper divisors of 28 are 1, 2, 4, 7 and 14, and they add up to exactly 28. A number like that is called perfect.
Write is_perfect(n) that returns True if the positive integer n is perfect and False otherwise.
is_perfect(6) # returns True (1 + 2 + 3 = 6) is_perfect(28) # returns True is_perfect(12) # returns False (1 + 2 + 3 + 4 + 6 = 16)
1 has no proper divisors, so their sum is 0 and 1 is not perfect.
First solves only, ranked by stars and then time.