Description
A perfect number is a positive integer that equals the sum of its positive divisors excluding itself. Given an integer n, return true if n is a perfect number, false otherwise. Example: 28 = 1 + 2 + 4 + 7 + 14.
Examples
Input:
num = 28Output:
trueExplanation:
28 = 1 + 2 + 4 + 7 + 14.
Input:
num = 7Output:
falseExplanation:
Divisors of 7 (excluding itself): only 1. Sum = 1, which does not equal 7.
Input:
num = 6Output:
trueExplanation:
Divisors of 6 (excluding itself): 1, 2, 3. Sum = 1+2+3 = 6, which equals the number.
Constraints
- •
1 ≤ num ≤ 10⁸