Module: Subroutines: procedures and functions - 2


Problem

8/10

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 and determines whether the number is perfect. Use the function to find the sum of the divisors of a number and the boolean function to check whether the number is perfect or not.

Input: input string contains natural number  ;.

Output: if number – perfect, the program should output the word 'YES', otherwise – the word 'NO'.

Examples.
Input Output
28 YES
29 NO