TI-89 program to search for Mersenne primes (and therby perfect


[Prev][Next][Index][Thread]

TI-89 program to search for Mersenne primes (and therby perfect numbers)



Hi

To get an idea on what Mersenne primes and perfect numbers are, go to

http://www.utm.edu/research/primes/mersenne.shtml

Here is a short program (my first ti program ever) that will accept a
positive integer p as input (should pe a prime), and then return true or
false depending on whether

2^p-1 is prime (called a Mersenne prime)

If 2^p-1 is prime, then

(2^p-1)*2^(p-1) is perfect, ie equal to the sum of all its divisors
(6=1+2+3, therefore perfect)

Only 37 perfect numbers are known, and the ti-89 are able to find the 14
smallest ones (the 14. has 366 digits)
The ti89 is thereby able to reach the same results as the best computers
did in 1952 (see above page)

For the 15. you will get an overflow.

Here is the program

(to search for Mersenne primes, include this in a for-loop that tests every
prime)

Mers(p)
Prgm
Local t,i,m
        4->t
        2^p-1->m
        For i,3,p
                mod(t^2-2,m)->t
        EndFor
        Disp t=0
EndPrgm

The test used is called the Lucas-Lehmer test.

I am a hp user, and a program written to do this test on my hp48GX found
the first 20 Mp's. The 20. perfect number has 2663 digits. It was first
discovered in 1961.

If anyone knows how to work with integers with more than 614 digits on the
89, I would like to know.


Christian
--
Christian Meland
Research Scientist, PFI
N-7034 Trondheim, Norway
Phone +4773550976, at home +47 73922526


Follow-Ups: