Mersenne Prime Checker
Test whether 2^p − 1 is a Mersenne prime for a given exponent p. Uses the Lucas–Lehmer primality test with an animated iteration trace, binary bit-pattern visualization, Euclid-Euler perfect-number pairing, and historical context on the 52 known Mersenne primes.
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
About Mersenne Prime Checker
Welcome to the Mersenne Prime Checker, an interactive tool that tests whether \(2^p - 1\) is a Mersenne prime for any exponent \(p\) up to 5000. The tool runs the celebrated Lucas-Lehmer primality test, shows an animated iteration trace of the recurrence \(S_i = S_{i-1}^2 - 2 \pmod{M_p}\), visualizes the binary bit pattern (a defining signature of every Mersenne number), and — when the result is prime — pairs it with the corresponding even perfect number via the Euclid-Euler theorem.
What Is a Mersenne Prime?
A Mersenne number is a number of the form \(M_p = 2^p - 1\). When \(M_p\) is itself prime, it is called a Mersenne prime. The name honors Marin Mersenne (1588-1648), the French monk who catalogued the early cases and conjectured which exponents up to 257 yielded primes — a list that turned out to be partly wrong, but launched three centuries of research.
The first few Mersenne primes, in order:
- \(M_2 = 3\)
- \(M_3 = 7\)
- \(M_5 = 31\)
- \(M_7 = 127\)
- \(M_{13} = 8{,}191\)
- \(M_{17} = 131{,}071\)
- \(M_{19} = 524{,}287\)
- \(M_{31} = 2{,}147{,}483{,}647\) (found by Euler in 1772 — the largest known prime for 104 years)
As of 2024, exactly 52 Mersenne primes are known. The current record is \(M_{136{,}279{,}841}\), discovered in October 2024 by the GIMPS distributed-computing project — a number with 41,024,320 decimal digits.
The Lucas-Lehmer Test
The reason Mersenne primes dominate the record books is a specialized, extremely fast primality test discovered by Édouard Lucas (1878) and simplified by Derrick Lehmer (1930):
For prime \(p \geq 3\): \(\;M_p\) is prime \(\iff S_{p-2} \equiv 0 \pmod{M_p}\)
The test requires only \(p-2\) modular squarings — roughly \(O(p^3)\) bit operations with schoolbook multiplication, or \(O(p^2 \log p \log\log p)\) with FFT. Compare this with general-purpose primality tests on numbers the size of \(M_p\) (millions of digits), which would be completely infeasible. The Lucas-Lehmer shortcut is what makes the Mersenne-prime search possible.
Why Must \(p\) Be Prime?
If \(p = a \cdot b\) with \(a, b > 1\), a classical identity shows that \(2^a - 1\) divides \(2^{ab} - 1\):
So if the exponent is composite, \(M_p\) is automatically composite. The converse is false: \(p\) being prime does not guarantee \(M_p\) is prime. For example, \(p = 11\) is prime but \(M_{11} = 2047 = 23 \times 89\).
Mersenne Primes and Perfect Numbers (Euclid-Euler)
Euclid observed around 300 BC that if \(2^p - 1\) is prime, then \(2^{p-1}(2^p - 1)\) is a perfect number — a number equal to the sum of its proper divisors. Euler later proved the converse: every even perfect number arises this way.
So finding a new Mersenne prime instantly produces a new perfect number. The first four even perfect numbers are 6, 28, 496, and 8128 — known since antiquity. Whether any odd perfect number exists remains an unsolved problem more than 2,300 years old.
The Binary Bit Pattern
Every Mersenne number has a uniquely clean binary representation: \(2^p\) in binary is \(1\) followed by \(p\) zeros, so \(2^p - 1\) is exactly \(p\) consecutive 1-bits:
This is why the tool visualizes each bit as its own tile — the bit pattern is the visual signature of a Mersenne number, independent of whether the number is prime.
How to Use This Calculator
- Enter an exponent \(p\): any positive integer from 1 to 5,000.
- Click Check: the tool first checks whether \(p\) is prime; if not, it explains why \(M_p\) must be composite.
- For prime \(p\): the Lucas-Lehmer recurrence runs \(p - 2\) iterations modulo \(M_p\).
- Explore the output: verdict banner, 6-row iteration trace (with "..." for omitted middle steps on large \(p\)), decimal and binary forms of \(M_p\), and the Euclid-Euler perfect-number pairing when applicable.
First Twelve Known Mersenne Primes
| # | Exponent \(p\) | \(M_p = 2^p - 1\) | Digits | Discovered |
|---|---|---|---|---|
| 1 | 2 | 3 | 1 | Ancient |
| 2 | 3 | 7 | 1 | Ancient |
| 3 | 5 | 31 | 2 | Ancient |
| 4 | 7 | 127 | 3 | Ancient |
| 5 | 13 | 8,191 | 4 | 1456 (anon.) |
| 6 | 17 | 131,071 | 6 | 1588 Cataldi |
| 7 | 19 | 524,287 | 6 | 1588 Cataldi |
| 8 | 31 | 2,147,483,647 | 10 | 1772 Euler |
| 9 | 61 | 2.3 × 10^18 | 19 | 1883 Pervushin |
| 10 | 89 | 6.2 × 10^26 | 27 | 1911 Powers |
| 11 | 107 | 1.6 × 10^32 | 33 | 1914 Powers |
| 12 | 127 | 1.7 × 10^38 | 39 | 1876 Lucas |
The GIMPS Project
The Great Internet Mersenne Prime Search (GIMPS), launched in 1996 by George Woltman, is a distributed-computing project where volunteers donate CPU time to run Lucas-Lehmer tests on candidate exponents. As of 2024, every Mersenne prime since M_35 = M_{1398269} (1996) has been discovered by GIMPS. A single Lucas-Lehmer test at the modern frontier (exponents near \(10^8\)) takes weeks of GPU computation.
Fun Facts About Mersenne Primes
- \(M_{31} = 2{,}147{,}483{,}647\) is the largest 32-bit signed integer — the famous \(\texttt{INT\_MAX}\) in C. This is no coincidence: the value comes from the fact that \(M_{31}\) is prime and therefore a natural "just-short-of-overflow" boundary.
- There are gaps of unknown size between successive Mersenne primes. It is not known whether there are infinitely many Mersenne primes — the Lenstra-Pomerance-Wagstaff conjecture predicts there are, growing roughly like \(e^\gamma \log_2 p\).
- In 2008, the Electronic Frontier Foundation awarded US$100,000 to the first discoverer of a 10-million-digit prime. The prize went to UCLA's GIMPS team for \(M_{43112609}\). A US$150,000 prize is still available for the first 100-million-digit prime.
- \(M_{31}\) appears on the 1811 Russian 100-ruble commemorative banknote honoring Euler's discovery — one of the few prime numbers ever printed on currency.
- Because every Mersenne prime yields a perfect number, humanity has exactly 52 even perfect numbers on file (matching the 52 known Mersenne primes).
Frequently Asked Questions
What is a Mersenne prime?
A Mersenne prime is a prime number of the form \(2^p - 1\), where \(p\) is also prime. The first few are 3, 7, 31, 127, and 8,191. As of 2024, 52 Mersenne primes are known; the largest known prime (\(M_{136{,}279{,}841}\)) is a Mersenne prime with over 41 million digits.
How does the Lucas-Lehmer test work?
For a prime exponent \(p \geq 3\), define \(S_0 = 4\) and \(S_i = S_{i-1}^2 - 2 \pmod{M_p}\). The Mersenne number \(M_p = 2^p - 1\) is prime if and only if \(S_{p-2} \equiv 0 \pmod{M_p}\). The test runs in \(p - 2\) iterations, each a single modular squaring.
Why must \(p\) be prime?
If \(p = ab\) with both factors greater than 1, then \(2^p - 1\) is divisible by \(2^a - 1\) (and by \(2^b - 1\)), so \(M_p\) is composite. The converse is not true: \(p\) being prime does not imply \(M_p\) is prime. For example \(p = 11\) is prime but \(M_{11} = 2047 = 23 \times 89\) is composite.
What is the connection between Mersenne primes and perfect numbers?
The Euclid-Euler theorem states that every even perfect number has the form \(2^{p-1}(2^p - 1)\) where \(2^p - 1\) is a Mersenne prime. So every Mersenne prime generates exactly one even perfect number, and every even perfect number comes from a Mersenne prime. Whether any odd perfect numbers exist is one of the oldest open problems in mathematics.
Why does \(M_p\) have \(p\) consecutive 1-bits in binary?
The number \(2^p\) in binary is a 1 followed by \(p\) zeros. Subtracting 1 converts all \(p\) trailing zeros into 1s. So \(2^p - 1\) in binary is exactly \(p\) ones — the defining visual signature of every Mersenne number, prime or composite.
What is the largest exponent this tool can test?
This tool tests exponents up to 5,000 so the Lucas-Lehmer iteration completes within a normal web request. For larger exponents (including the GIMPS frontier near \(10^8\)), dedicated software such as Prime95 is required since a single test can take weeks of compute time on a modern GPU.
Additional Resources
- Mersenne Prime - Wikipedia
- Lucas-Lehmer Primality Test - Wikipedia
- Perfect Number - Wikipedia
- GIMPS: Great Internet Mersenne Prime Search
- OEIS A000043: Mersenne prime exponents
Reference this content, page, or tool as:
"Mersenne Prime Checker" at https://MiniWebtool.com/mersenne-prime-checker/ from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: Apr 18, 2026
You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.
Basic Math Operations:
- Common Factor Calculator
- Cube and Cube Root Calculator
- Cube Root Calculator
- Divide Into Two Parts
- Divisibility Test Calculator
- Factor Calculator
- Find Minimum and Maximum
- First n Digits of e
- First n Digits of Pi Featured
- Greatest Common Factor Calculator
- Is it a Prime Number?
- Least Common Multiple Calculator
- Modulo Calculator Featured
- Multiplication Calculator
- n-th Root Calculator
- Number of Digits Calculator Featured
- Prime Factor Calculator
- Prime Factorization Calculator
- Quotient and Remainder Calculator Featured
- Sort Numbers Featured
- Square Root (√) Calculator Featured
- Sum Calculator Featured
- Ratio Calculator New
- Long Division Calculator New
- Cross Multiplication Calculator New
- Multiplication Table Generator New
- Long Multiplication Calculator New
- Long Addition and Subtraction Calculator New
- Order of Operations Calculator (PEMDAS) New
- Place Value Chart Generator New
- Number Pattern Finder New
- Even or Odd Number Checker New
- Absolute Value Calculator New
- Ceiling and Floor Function Calculator New
- Unit Rate Calculator New
- Skip Counting Generator New
- Estimation Calculator New
- Perfect Number Checker New