Write a function that tells if a natural n is perfect.
A natural number is called perfect if it is equal to the sum of all its divisors except itself. For instance, 28 is perfect, because 28=1+2+4+7+14.
Interface
C++ | bool is_perfect(int n); |
C | int is_perfect(int n); |
Java | public static boolean isPerfect(int n); |
Python | is_perfect(n) # returns bool |
is_perfect(n: int) -> bool |
Precondition
n is a natural number.
Observation You only need to submit the required procedure; your main program will be ignored.
Input/Output