home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!math.fu-berlin.de!uni-paderborn.de!urmel.informatik.rwth-aachen.de!gmd.de!newsserver.jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!ns1.cc.lehigh.edu!mal4
- From: mal4@ns1.cc.lehigh.edu (Marty Lamb)
- Newsgroups: comp.programming
- Subject: Re: how about PRIME numbers ?
- Message-ID: <1993Jan27.175613.62630@ns1.cc.lehigh.edu>
- Date: 27 Jan 93 17:56:13 GMT
- Organization: Lehigh University
- Lines: 52
-
- In article <4671@sicsun.epfl.ch>, guglielmetti@elia.epfl.ch (Philippe Guglielmet
- ti) writes:
- >Hi!
- >about primes, I've read somewhere that it is possible to check if a
- >really large "candidate" number like 2^245-1 is prime or not in a
- >reasonable time using "congruence", without generating all the primes and
- >without looking for divisors (which is roughly equivalent) but I didn't
- >really understood how it worked in practice. Does anyone have code for
- >this ?
- >
-
- I haven't got code, but it's a simple (or at least simply implemented)
- algorithm. I have ABSOLUTELY NO IDEA why it works, so if anyone does I'm sure
- it's interesting enough to post.
-
- A number of the form 2^p - 1 (p is an integer) is called a Mersenne Number,
- after the mathematician whose first name currently escapes me. The algorith
- goes like this:
-
- p = exponent to test
- MersenneNumber = 2^p - 1
-
- Start with L = 4
- |--> set L = L^2 - 2 MOD MersenneNumber -----|
- |<----- do this p - 2 times <-----------------|
- If L = 0 then the Mersenne Number is prime.
-
- It's amazingly quick, with the HUGE disadvantage that you have to calculate
- the Mersenne Number, although I suppose a clever MOD subroutine might be able
- to bypass that.
-
-
- >I remember that this what makes modern "revealed key encryption" feasible
- >since the public key is the the product of 2 large prime numbers (which
- >form the private key used in decryption). If I understood correctly, it
- >was formally prooved that no polynomial time algorithm exists to
- >decompose a number in its prim e factor...
- >
- >
- >Ph. Guglielmetti
- >
-
-
- Marty Lamb
- --
-
- ___________________________________________________________________________
- /-------------------------------------------------------------------------/|
- | Be like the 22nd elephant with | Marty Lamb (215)758-1921 ||
- | heated value in space. Bark! | Box 0151 ||
- |-------------------------------------- Lehigh University ||
- | mal4@lehigh.edu | 29 Trembley Dr. ||
-