Input a number to check if it's a perfect number, or input a range to generate all perfect numbers within that range.
A perfect number, also called a complete or ideal number, is a positive integer that equals the sum of its proper divisors (excluding itself). For example:
- 6 is a perfect number because its divisors are 1, 2, and 3, and 1 + 2 + 3 = 6.
- 28 is also a perfect number because its divisors are 1, 2, 4, 7, and 14, and 1 + 2 + 4 + 7 + 14 = 28.
Solution:
1. Find the divisors:
The proper divisors of 12 are 1, 2, 3, 4, and 6.
2. Sum the divisors:
1 + 2 + 3 + 4 + 6 = 16
Thus, 12 is not a perfect number since the sum is greater than 12.
Solution:
1. Find the divisors:
The proper divisors of 496 are 1, 2, 4, 8, 16, 31, 62, 124, and 248.
2. Sum the divisors:
1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248 = 496
Conclusion: 496 is a perfect number since the sum equals 496.
o date, 51 perfect numbers have been discovered. The first 10 are: