Home | AVR | FPGAM680x | Zilog Z8 | Zilog Z80 | Hitachi SH | Transputer | Linux | DOS

 

Go back to download area Perfect

What is a Perfect Number?

A Perfect number is a number which has all its integer factors added together to result in the source number. Known Perfect numbers to date are: 1, 6, 28, 496, 8128 and 33,552,384.

The algorithm for calculating these numbers is similar to Prime numbers accept the results are rare and the sum of its factors gives the source number again.

For example to test if a number is perfect all of its integer factors need to be found then added together, not including the original number, and if the result matches the original number then the number is perfect.

Here are a few simple examples.

eg: (6) 1+2+3=6 (Perfect)
eg: (8) 1+2+4=7 (Not perfect)

Linear Search Method

Here is a typical 'C' program that would sequentially search every number, starting at 2 and proceed up in increments of 2. It steps up by 2 because, so far, no odd number has been found to be perfect therefore the search time is reduced by two and eliminating unnecessary testing.

Click here to download source code to Perfect search program

Power Search Method

The program can also search using this incomplete mathematical formulae that effectively shortens the search process.

p = 2n-2abs(n >> 1)

The problem with this approach now is that integer numbers, as represented in 32 bit computers, can not go further than 4,294,967,296 and the sequence for "n" is also unknown.

The numerical ceiling can be easily fixed with large number arrays and algorithms that work on them. However, "n" is a little harder. (Any ideas?)

By using a sequential iteration for "n" and "plugging" it into the equation above, and then testing the resultant number "p" for perfect ness, has yielded a 6th Perfect number in a very short time with very little effort. 

The actual measured time for the search to report the 6th Perfect number's existence took less than a minute on a 486DX2-66 computer. To do it the old linear way would have taken hundreds of years on the same type of computer, which sort of indicates that the search method is getting better.

So far all known Perfect numbers are:

1 21 - 20
6 23 - 21
28 25 - 22
496 29 - 24
8128 213 - 26
33550336 225 - 212

The program that did this search and found the 6th Perfect number can be downloaded here.

The other neat thing about Perfect number search algorithms is that they keep a CPU busy for an extended length of time which makes it great for testing and bench-marking new computer systems.

This page was last updated: Friday, February 07, 2003 14:54 Au EST.