Perfect Numbers
A perfect number is an integer whose factors (excluding itself) sum up to the number itself. For example, perfect numbers are:
- 6, because or , and .
- 28, because , , or , and .
Write a program that takes integers as input and determines whether they are perfect numbers. The number 1 is not considered a perfect number.
Input:
The input file will be named input.txt and will be located in the directory where your program is executed. Each of it's lines will consist of a positive integer that you need to check if it is perfect.
Output:
The output file will be named output.txt and will be located in the directory where your program is executed. Each of it's lines will contain either of the two numbers: or .
- 0: if the number on the corresponding line of the input file is not perfect.
- 1: if the number on the corresponding line of the input file is perfect.
Examples of Input - Output Files
STDIN (INPUT.TXT)
500
6
15
12
28
STDOUT (OUTPUT.TXT)
0
1
0
0
1
Note:
The executable file to be created should be named perfect.exe.
ATTENTION! You must strictly adhere to the names and structure of the files; otherwise, your answer will be considered incorrect during evaluation.
Comments