JuniorMath
Perfect Number
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly.
Given an integer num, return true if num is a perfect number, otherwise return false.
Example 1
Input
num = 28Output
true28 is equal to the sum of its positive divisors excluding itself: 1 + 2 + 4 + 7 + 14.
Example 2
Input
num = 7Output
false7 is not equal to the sum of its positive divisors excluding itself.
Constraints
- 1 <= num <= 10^8