Re: how to check if 2^n-1 is prime for some n ?

From: Dale Henderson (nilram_at_hotpop.com)
Date: 06/10/04


Date: 10 Jun 2004 12:21:52 -0500


>>>>> "Basel" == Basel Naamna <baseln@yahoo.com> writes:

    Basel> is there an algorithm to check of the 2^n-1 is prime?

    Yes.
     
    Numbers of the form 2^n-1 are called Mersenne numbers and primes
    of the this form are known as Mersenne primes. To date 41 Mersenne
    primes have been found. The most recent was found in May!

    Probably the most common approach is to use the Lucas-Lehmer test.

    Let L_1=4.
    Define L_n=l_(n-1)^2-2.

    2^n-1 is prime if and only if 2^n-1 divides L_(n-1) (equivalently
    L_(n-1) = 0 (mod 2^n-1))

    In practice calculation of L_k is done mod (2^n-1) since the L_k
    grows *very* fast (L_6 has 18 digits!).

    Since the Lucas-Lehmer test can be computationally taxing it is best
    to perform some more basic checks first.

    First check the primality of n. 2^n-1 can only be prime if n is
    prime. (otherwise 2^n-1 is divisible by 2^k-1 where k divides n) Of
    course this implies that n must be odd (or 2 but one would assume we
    want n>2).

    Another test that can be performed is to check for the primality of
    2n+1. If n and 2n+1 are both prime then 2^n-1 is not prime.

    For more information see
    http://www.utm.edu/research/primes/mersenne/index.html

--
Dale Henderson 
"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..."  -- G. H. Hardy


Relevant Pages

  • Re: Mersenne primes and composites
    ... is integer for any n which is a compostite of up to two mersenne ... primes. ... Gerry Myerson ...
    (sci.math)
  • Re: Sandwich primes!
    ... > The Mersenne numbers for all odd ... > or even with a 97 appended has primes ... > where the Mersenne primes only have ... > for the first 25 prime exponents. ...
    (sci.math)
  • Re: why cannot Davidson and Dubuque write a proof with detail?
    ... Hardy below shows you wrong. ... You pull the word, contradiction out ... and you mistakenly think it covers the supposition primes are finite. ... a,b,c are the omly primes that exist and that PRIMES is a finite set. ...
    (sci.math)
  • Re: Problem about divisibility
    ... decomposition into primes. ... your definition is _not_ the way Hardy & Wright define lcm. ...
    (sci.math)