the Guiness Book mentiones a number called "Perfect Number" (in German: "Perfekte Zahl"). it's a number which is the sum of all its divisors except itself.
e.g.: 6
6 = 3 + 2 + 1
another example is 28 (1, 2, 4, 7, 14)

can anybody help me with an algo? i once had one in pascal, but that was soo fu**ing slow, it found about 2 or 3 number in 2 minutes.

tia
Posted on 2002-10-02 17:27:44 by ploptor
There are only 38 known perfect numbers and only 5 that can fit in a 32bit register so your best bet would just be to store them as an array and compare them.

``perf_nums dd 6, 28, 496, 8128, 33550336``

If you want to work with 64 bits then add 3 more numbers to that list: 8,589,869,056 - 137,438,691,328 - and 2,305,843,008,139,952,128.

As you can see it's kind of pointless ;) Here are a few more of them: 2,658,455,991,569,831,744,654,692,615,953,842,176 - 191,561,942,608,236,107,294,793,378,084,303,638,130,997,321,548,169,216.
Posted on 2002-10-02 18:14:14 by iblis
ummm, I'm not sure but I remember something like this.

1. pick a number
2. let this number be n
3. x = (2^n) - 1
4. if x is a prime number, continue. Else....
5. y = (2^(n-1)) * ((2^n)-1)
6. y is a perfect number

I guess the problem here is looking for the fastest algorithm to determine if a number is prime. 2 months ago, I've heard a news about a new discovery to determine if the number is prime, they claim it's the fastest. I can't remember most of the story nor the name of the algorithm.
Posted on 2002-10-02 19:42:50 by stryker

2 months ago, I've heard a news about a new discovery to determine if the number is prime, they claim it's the fastest. I can't remember most of the story nor the name of the algorithm.

http://www.cse.iitk.ac.in/primality.pdf
Posted on 2002-10-02 19:58:51 by Tola
yes, that's the one I was looking for. Thanks. :alright:
Posted on 2002-10-02 21:10:29 by stryker
That algo is certainly not the fastest. But it's the fastest exact algo.

Anyway, 2^p-1 is a Mersenne prime and there are better ways to test if it really is a prime or not. Check http://www.mersenne.org/prime.htm

The largest know prime is here (recently discovered):
http://www.utm.edu/research/primes/notes/13466917/index.html.
Posted on 2002-10-03 00:46:34 by gliptic
It takes a perfect mind to find a perfect number. <g>
Posted on 2002-10-03 19:27:35 by Ernie