Logic functions. Perfect Numbers
Problem
A perfect number is a number equal to the sum of all its divisors less than itself (for example, the number 6=1+2+3). Write a program that takes a natural number N and determines whether the number N is perfect. Use a function to find the sum of the divisors of a number and a logical function to check whether the number is perfect or not.
Input: The input string contains a natural number N .
Output: If a number N – perfect, the program should output the word 'YES', otherwise – the word 'NO'.
Examples
# |
Input |
Output |
1 |
28 |
YES |
2 |
29 |
NO |