Mersenne Prime Checker
Check if 2p−1 is prime using the Lucas-Lehmer test
Exponents up to 127 are computed exactly with BigInt (for larger, see the list). p must be prime for 2^p−1 to have a chance of being prime.
All 51 known Mersenne primes as of 2024. Mersenne primes are primes of the form 2p−1.
| # | p | 2^p − 1 | Digits | Discovered | By |
|---|
The Lucas-Lehmer test checks if Mp = 2p−1 is prime. Start with s₀ = 4, then si+1 = si² − 2 (mod Mp). Mp is prime iff sp−2 ≡ 0 (mod Mp).
For pedagogical purposes, steps are shown for p ≤ 61 (larger values would have too many steps to display).
About Mersenne Primes
A Mersenne prime is a prime of the form 2p−1, where p itself must be prime (though not every prime p gives a Mersenne prime). They are named after Marin Mersenne (1588–1648), a French monk who studied them extensively.
Key facts:
- Only 51 Mersenne primes are known (as of 2024)
- The largest known prime is always a Mersenne prime
- The current record (M82589933) has 24,862,048 digits
- The GIMPS project uses distributed computing to find new ones
- It is unknown whether infinitely many Mersenne primes exist
Frequently Asked Questions
Why must p be prime for 2^p−1 to be prime?
If p = ab (composite) with a, b > 1, then 2^a − 1 divides 2^(ab) − 1. So 2^p − 1 would be composite. Therefore, a Mersenne prime's exponent must itself be prime — though the converse is not guaranteed (not all prime exponents give Mersenne primes).
How does the Lucas-Lehmer test work?
For odd prime p, define s₀ = 4 and s_{i+1} = s_i² − 2 (mod 2^p − 1). The Mersenne number M_p = 2^p − 1 is prime if and only if s_{p−2} ≡ 0 (mod M_p). This test is highly efficient compared to general primality tests because it exploits the special structure of Mersenne numbers.
What is the GIMPS project?
The Great Internet Mersenne Prime Search (GIMPS) is a distributed computing project where volunteers run software on their computers to test potential Mersenne primes. Started in 1996, GIMPS has discovered all Mersenne primes since M35 (2^1,398,269−1). Discoverers can earn cash prizes for finding new Mersenne primes.
Are Mersenne primes connected to perfect numbers?
Yes! Every even perfect number has the form 2^(p−1) × (2^p − 1) where 2^p − 1 is a Mersenne prime. This was proved by Euler (and partially by Euclid). The first four perfect numbers are 6, 28, 496, and 8128 — corresponding to Mersenne primes with p = 2, 3, 5, 7.
What's the largest known Mersenne prime?
As of 2024, the largest known Mersenne prime is 2^82,589,933 − 1, discovered by Patrick Laroche in December 2018. It has 24,862,048 decimal digits and is also the largest known prime of any kind.
Are there infinitely many Mersenne primes?
This is unknown. The Lenstra-Pomerance-Wagstaff conjecture predicts there are infinitely many, growing at roughly e^γ × ln(2) × ln(ln(x)) Mersenne primes up to exponent x — but no proof exists.
Who was Marin Mersenne?
Marin Mersenne (1588–1648) was a French Minim friar, theologian, philosopher, and mathematician. He corresponded with major mathematicians of his era (Fermat, Pascal, Descartes) and is credited with proposing that numbers of the form 2^p−1 might often be prime. He correctly identified several Mersenne primes but also made some errors in his list.
Is there a pattern to Mersenne prime exponents?
No clear pattern has been found. The exponents (2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127…) appear somewhat irregular. Many primes in between (like 11, 23, 29, 37…) do not yield Mersenne primes. Finding the next one requires exhaustive computer testing.