Module: (Java) Subroutines: Procedures and Functions - 2


Problem

9/11

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  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 .

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

Examples
# Input Output
1 28 YES
2 29 NO