In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of October 26th
(this exercise will still be available for submission after that deadline, but without couting towards your grade)
[to understand the context of this problem, you should read the class #03 exercise sheet]
Are you a perfectionist? Well, in the mathematical world, perfection has a whole new meaning! A perfect number is a number that is equal to the sum of its proper divisors (excluding itself). For example, 6 is a perfect number because its divisors (3, 2, and 1) sum to 6 (
3 + 2 + 1 = 6
).
Write a program that checks if a given positive integer number num is a perfect number. If it is, your program should also display its proper divisors (the factors that add up to the number). For instance, if the input number is 6, your program should output:
6 is a perfect number Factors: 3 2 1
The input consists of a single integer num.
The output should indicate whether the number is perfect, along with its factors if it is indeed perfect. The factors should come in decreasing order and should be separateed by single space (with no space after the last number).
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ num ≤ 500 | The input number must be a positive integer |
Example Input 1 | Example Output 1 |
6 |
6 is a perfect number Factors: 3 2 1 |
Example Input 2 | Example Output 2 |
7 |
7 is not a perfect number |