Check if Number is Perfect
E · easyP · Verified PYQmath
Problem
A perfect number equals the sum of its proper divisors (excluding itself). Check if a given number N is perfect. Example: 28 = 1 + 2 + 4 + 7 + 14 = 28 → Perfect
Example
Input
28
Output
YES
Loop from 1 to N//2. Sum all divisors. Compare to N. Edge case: N=1 is not perfect.