#K61422. Perfect Number Checker
Perfect Number Checker
Perfect Number Checker
In this problem, you are given a positive integer n. Your task is to determine whether n is a perfect number or not.
A perfect number is defined as a positive integer that is equal to the sum of its proper positive divisors, excluding itself. For example, 6 is a perfect number because its proper divisors are 1, 2, and 3, and 1 + 2 + 3 = 6.
The mathematical definition can be expressed in LaTeX as follows:
$$ n = \sum_{i=1}^{n-1} \textbf{1}_{(n \bmod i = 0)} \cdot i $$
Your program should read an integer from standard input and print YES
if the number is perfect, otherwise print NO
.
inputFormat
The input consists of a single integer n ($1 \leq n \leq 10^8$) provided in a single line from standard input.
outputFormat
Output a single line containing YES
if n is a perfect number, or NO
otherwise.
6
YES