University of Calgary

perfect numbers

Perfect Numbers
from: CC Small College Computing Conference 5th Programming Contest

If N is a positive integer, let S(N) be the sum of the proper divisors of N (i.e. divisors of N other than N itself).

For example, S(12) = 1+2+3+4+6=16, S(7)=1, S(6)=1+2+3=6.

Note that sometimes S(N) is larger than N (as in S(12)) sometimes its smaller (as in S(7)) and sometimes it's exactly equal (as in S(6)).

Numbers for which S(N)=N are called perfect numbers, and have been a curiosity in the mathematics of number theory for over 2000 years.

Your task is to write a program that finds the first four perfect numbers and the number of digits in each. Don't try to go beyond this limit of four, becase these numbers grow very quickly. For example, the ninth perfect number has thirty-seven digits.



Updated: August 10, 2005 10:15 AM