44. Perfect Donation Amount
Difficulty: easy · Math, Number Theory
Problem
A charity considers a donation amount **perfect** if it equals the sum of its proper divisors (all positive divisors other than the number itself). For example `28 = 1 + 2 + 4 + 7 + 14`. Given a donation amount `n`, print `true` if it is perfect and `false` otherwise.
Input
A single line containing the integer `n`.
Output
Print `true` or `false`.
Example 1
Input: 28 Output: true
Explanation: The proper divisors 1, 2, 4, 7 and 14 add up to 28.
Example 2
Input: 12 Output: false
Explanation: 1 + 2 + 3 + 4 + 6 = 16, which is not 12.
Constraints
- 1 <= n <= 10^12
Solutions are judged against 2 sample and 11 hidden tests. Sign in to solve it · All problems