TOPICS
Search

Lucas-Lehmer Test


The Lucas-Lehmer test is an efficient deterministic primality test for determining if a Mersenne number M_n is prime. Since Mersenne numbers can only be prime for prime indices, attention can be restricted to Mersenne numbers of the form M_p=2^p-1, where p is an odd prime.

Consider the recurrence equation

 s_n=s_(n-1)^2-2 (mod M_p)
(1)

with s_0=4. For example, ignoring the congruence, the first few terms of this iteration are 4, 14, 194, 37634, 1416317954, ... (OEIS A003010).

It turns out that M_p is prime iff s_(p-2)=0 (mod M_p), and the value s_(p-2) (mod M_p) is called the Lucas-Lehmer residue for p.

For example, the sequence obtained for p=7 is given by 4, 14, 67, 42, 111, 0, so M_7=127 is prime.

Including the value 1 for p=2 from s_0 (mod 3), the first few Lucas-Lehmer residues for prime number exponents are 1, 0, 0, 0, 1736, 0, 0, 0, 6107895, 458738443, 0, 117093979072, ... (OEIS A095847).

For general integers, Pratt (1975) developed recursive primality certification using the prime factorization of n-1. The resulting certification is known as a Pratt certificate.

A related N+1 primality test for an odd number N>1 starts with the complete prime factorization

 N+1=product_(j=1)^nq_j^(beta_j),
(2)

with q_j the distinct prime factors, and beta_j their respective positive integer exponents. If there exists a Lucas sequence U_nu=U_nu(P,Q) with integer parameters P, Q and GCD(2QD,N)=1, where D=P^2-4Q, such that

 GCD(U_((N+1)/q_j),N)=1
(3)

for j=1, ..., n and

 U_(N+1)=0 (mod N),
(4)

then N is a prime number (Brillhart et al. 1975, Ribenboim 2004).


See also

Lucas Sequence, Mersenne Number, Mersenne Prime, Pratt Certificate, Rabin-Miller Strong Pseudoprime Test

Explore with Wolfram|Alpha

References

Brillhart, J.; Lehmer, D. H.; and Selfridge, J. L. "New Primality Criteria and Factorizations of 2^m+/-1." Math. Comput. 29, 620-647, 1975. https://doi.org/10.2307/2005583.Knuth, D. E. §4.5.4 in The Art of Computer Programming, Vol. 2: Seminumerical Algorithms. Reading, MA: Addison-Wesley, 1969.Numberphile. "How They Found the World's Biggest Prime Number." Jan. 21, 2016. https://www.youtube.com/watch?v=lEvXcTYqtKU.Pratt, V. "Every Prime Has a Succinct Certificate." SIAM J. Comput. 4, 214-220, 1975. https://doi.org/10.1137/0204018.Ribenboim, P. "Primality Tests Based on Lucas Sequences." §2.V in The Little Book of Bigger Primes, 2nd ed. New York: Springer-Verlag, p. 63, 2004.Sloane, N. J. A. Sequences A003010/M3494 and A095847 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Lucas-Lehmer Test

Cite this as:

Weisstein, Eric W. "Lucas-Lehmer Test." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Lucas-LehmerTest.html

Subject classifications