Perfect Number Check
InterviewTime limit2sMemory limit128 MB
Decide whether each given integer equals the sum of its proper divisors and print the equation or a negative verdict.
- Level
Easy2 of 10
- Topics
- Number theory, Implementation
- Solved
- No attempts yet
Problem
A number is a perfect number if it equals the sum of all its divisors except itself.
For example, , so is perfect.
Write a program that decides whether is a perfect number.
Input
The input holds several test cases, one integer per line ().
The last line of the input is , and that line is not processed. The number of test cases is not given in advance.
Output
Print one line per test case.
If is perfect, print it as n = d1 + d2 + ... + dk, where are the divisors of other than itself, in ascending order. Put one space on each side of the equals sign and of every plus sign.
If is not perfect, print n is NOT perfect.