Mersenne Prime Checker
Test a candidate of the form 2^p − 1 with MiniWebtool’s Mersenne Prime Checker. A Lucas-Lehmer iteration trace explains the primality test, with binary-pattern visuals and the related perfect number for qualifying primes.
For Gemini, paste the copied question into the chat. You can also copy it below.Need help using this tool? Ask AI
View the question
Enter an exponent p below to test whether 2^p − 1 is a Mersenne prime, with the Lucas–Lehmer trace and the bit pattern.
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.
At a Glance
Mersenne Prime Checker tests whether 2^p - 1 is a Mersenne prime for any exponent p from 1 to 5,000. It runs the Lucas-Lehmer test and shows the iteration trace and binary form.
| Feature | What you get | Good for |
|---|---|---|
| Exponent input | Enter a positive integer exponent p from 1 to 5,000 and the tool tests M_p = 2^p - 1. | Checking a specific exponent such as 11, 13 or 127 |
| Prime exponent check | First checks whether p is prime. If it is not, the tool explains why M_p must be composite. | Understanding why composite exponents fail |
| Lucas-Lehmer test | For prime p, runs the recurrence S_i = S_(i-1)^2 - 2 mod M_p for p - 2 iterations and gives a prime or composite verdict. | Seeing how the classic primality test works |
| Iteration trace | Shows a 6-row trace of the iterations, with the middle steps omitted for large p. | Following the recurrence without every step |
| Binary pattern | Shows M_p in decimal and binary, with each of the p one-bits as its own tile. | Seeing why Mersenne numbers are all ones in binary |
| Perfect number | When M_p is prime, shows the matching even perfect number 2^(p-1) x (2^p - 1). | Exploring the Euclid-Euler link |
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. It equals \(2^{31} - 1\) because a 32-bit two's-complement integer has 31 magnitude bits; that this number is also prime is pure coincidence.
- 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.
- 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
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
Chat with your favorite AI
For Gemini, paste the copied question into the chat. You can also copy it below.
View the question
Basic Math Operations:
- Absolute Value Calculator New
- Amicable Number Checker New
- Carry and Borrow Visualizer New
- Ceiling and Floor Function Calculator New
- Common Factor Calculator
- Cross Multiplication Calculator New
- Cube and Cube Root Calculator
- Cube Root Calculator
- Digital Root Calculator New
- Divide Into Two Parts
- Divisibility Test Calculator
- Egyptian Multiplication Calculator New
- Estimation Calculator Popular
- Even or Odd Number Checker New
- Factor Calculator
- Fibonacci Number Checker New
- Find Minimum and Maximum
- First n Digits of e Popular
- First n Digits of Pi Popular
- Goldbach Conjecture Verifier New
- Greatest Common Factor Calculator
- Is it a Prime Number?
- Least Common Multiple Calculator
- Long Addition and Subtraction Calculator New
- Long Division Calculator New
- Long Multiplication Calculator Popular
- Möbius Function Calculator New
- Mental Math Trainer New
- Mersenne Prime Checker New
- Modulo Calculator Popular
- Multiplication Calculator Popular
- Multiplication Table Generator New
- n-th Root Calculator
- Number Bonds Generator New
- Number of Digits Calculator Popular
- Number Pattern Finder Popular
- Order of Operations Calculator (PEMDAS) New
- Perfect Number Checker New
- Place Value Chart Generator New
- Prime Factor Calculator
- Prime Factorization Calculator
- Quotient and Remainder Calculator Popular
- Random Math Problem Generator Popular
- Ratio Calculator New
- Roman Numeral Math Solver New
- Russian Peasant Multiplication New
- Skip Counting Generator New
- Soroban Abacus Simulator New
- Sort Numbers Popular
- Square Root (√) Calculator
- Sum Calculator Popular
- Times Tables Quiz New
- Unit Rate Calculator New
- Vedic Math Tricks Calculator New