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 = 28
Output:true
Explanation:

28 = 1 + 2 + 4 + 7 + 14.

Input:num = 7
Output:false
Explanation:

Divisors of 7 (excluding itself): only 1. Sum = 1, which does not equal 7.

Input:num = 6
Output:true
Explanation:

Divisors of 6 (excluding itself): 1, 2, 3. Sum = 1+2+3 = 6, which equals the number.

Constraints

  • 1 ≤ num ≤ 10⁸

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!