Since 2010 · Powering 2M+ tool runs every month
Since 2010
Add to Chrome

My Toolbox

Automatic Mode

No saved tools yet.

Go Premium
Related tools
Fibonacci Number CheckerTwin Prime FinderModular Exponentiation CalculatorMurmurHash3 Generator
Home Page > Math > Basic Math Operations

Mersenne Prime Checker

Test whether 2^p - 1 is a Mersenne prime for a given exponent p. Uses the Lucas-Lehmer test with an animated iteration trace, a binary bit-pattern visual, Euclid-Euler perfect-number pairing and the 52 known Mersenne primes.

Free to useNo sign-up requiredInstant Results
Mersenne Prime CheckerTry it now — free ▼

Pick a famous exponent to test — each one runs in milliseconds:

✦ Known prime \(M_p\) p = 13 p = 17 p = 31 p = 61 p = 127
✕ Composite \(M_p\) p = 11 p = 23 p = 37 p = 67
2^

Any positive integer from 1 to 5,000. For larger exponents use specialized software like Prime95.

Embed Mersenne Prime Checker Widget

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.

Mersenne Prime
$$M_p = 2^p - 1 \;\; \text{is prime, where } p \text{ itself must be prime}$$

The first few Mersenne primes, in order:

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):

Lucas-Lehmer Test
$$S_0 = 4, \quad S_i = S_{i-1}^2 - 2 \pmod{M_p}$$

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\):

Factoring identity
$$2^{ab} - 1 = (2^a - 1)\left(2^{a(b-1)} + 2^{a(b-2)} + \cdots + 2^a + 1\right)$$

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.

Euclid-Euler Theorem
$$N \text{ is an even perfect number} \iff N = 2^{p-1}(2^p - 1),\;\; 2^p - 1 \text{ prime}$$

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:

M_5 = 2^5 − 1 = 111112 = 31
M_7 = 2^7 − 1 = 11111112 = 127

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

  1. Enter an exponent \(p\): any positive integer from 1 to 5,000.
  2. Click Check: the tool first checks whether \(p\) is prime; if not, it explains why \(M_p\) must be composite.
  3. For prime \(p\): the Lucas-Lehmer recurrence runs \(p - 2\) iterations modulo \(M_p\).
  4. 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\)DigitsDiscovered
1231Ancient
2371Ancient
35312Ancient
471273Ancient
5138,19141456 (anon.)
617131,07161588 Cataldi
719524,28761588 Cataldi
8312,147,483,647101772 Euler
9612.3 × 10^18191883 Pervushin
10896.2 × 10^26271911 Powers
111071.6 × 10^32331914 Powers
121271.7 × 10^38391876 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

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

You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.

Basic Math Operations:

Top & Updated:

Perfect Number CheckerAmicable Number CheckerIs it a Prime Number?View all →
Home Page > Math > Basic Math Operations > Mersenne Prime Checker