Quote:
> While reading Simon Singh's book, "Fermat's Last Theorem", I got
> the urge to try and code some of the ideas in Forth. Hopefully
> somebody will find it amusing.
Unfortunately, Mr. Singh was not completely accurate in his description
of Perfect Numbers (or maybe I didn't read the text carefully enough).
In my program I used that Euclid found that perfect numbers are always
a multiple of two numbers n1 and n2, n1 a power of two, n2 the next power
of 2 minus 1:
6 = 2^1 * (2^2 - 1)
28 = 2^2 * (2^3 - 1)
496 = 2^4 * (2^5 - 1)
8,128 = 2^6 * (2^7 - 1)
What the book didn't say is that in addition Euclid found that when n2
is prime, n automatically is a perfect number. This opens the door to
finding much larger Perfect Numbers, because [probability] algorithms
exist that can test if a number is prime.
I've written a Forth program that will check that, e.g., 2^3217 - 1 is
prime and prints out the accompanying Perfect Number. For the given number
the check takes only a few seconds on a P54C-166. (I can't show these numbers
as my news reader thinks I'm trying to post a binary in a non-binary group).
The program can be found on http://www.*-*-*.com/
-marcel