Maths WorkshopMaths problems with full solutions
Exercise 2194Number theory › PrimesM1Added 3 Nov 2026

The Lucas–Lehmer test

#Lucas-Lehmer#Mersenne#primality

Statement

State the Lucas–Lehmer test for Mersenne primes and apply it to M3=7M_3=7.

Hint

Define s0=4s_0=4, sn+1=sn2−2 mod Mps_{n+1}=s_n^2-2\bmod M_p. MpM_p is prime iff sp−2≡0(modMp)s_{p-2}\equiv0\pmod{M_p}.

Show solutionHide solution

Solution

Test. For pp prime, Mp=2p−1M_p=2^p-1 is prime iff sp−2≡0(modMp)s_{p-2}\equiv0\pmod{M_p}, where s0=4s_0=4 and sn+1=sn2−2s_{n+1}=s_n^2-2.

Apply to p=3p=3. M3=7M_3=7. s0=4s_0=4. s1=42−2=14≡0(mod7)s_1=4^2-2=14\equiv0\pmod7. Since p−2=1p-2=1 and s1≡0s_1\equiv0, M3M_3 is prime. ✓

Conclusion. Lucas–Lehmer is a fast test for Mersenne primes; used to find the largest known primes.