Mersenne Prime Checker Calculator

Test exponents, inspect residues, and verify special prime forms. View sequence behavior, digit growth, and final verdict clearly.

Calculator Input

Example Data Table

Exponent p M = 2^p - 1 Exponent Prime? Mersenne Prime?
23YesYes
37YesYes
531YesYes
112047YesNo
138191YesYes
17131071YesYes
19524287YesYes
312147483647YesYes

Formula Used

A Mersenne number has the form Mp = 2p - 1. A necessary condition is that p itself must be prime. That condition alone is not enough, so this calculator also applies the Lucas–Lehmer primality test.

Mp = 2p - 1
s0 = 4
sn+1 = sn2 - 2 (mod Mp)
Mp is prime if and only if sp-2 ≡ 0 (mod Mp)

The calculator estimates decimal, binary, and hexadecimal length, checks whether the exponent is prime, and then evaluates the Lucas–Lehmer residue. A zero final residue means the candidate is a Mersenne prime.

How to Use This Calculator

  1. Choose whether to enter an exponent or a candidate value.
  2. Enter prime exponent p, or a number of the form 2^p - 1.
  3. Set how many Lucas–Lehmer steps you want previewed in the table.
  4. Click Check Mersenne Prime to generate the result.
  5. Review the verdict, residue, digit counts, and iteration summary.
  6. Inspect the sequence table and graph for behavior across iterations.
  7. Use the CSV or PDF buttons to export the visible result table.

Frequently Asked Questions

1. What is a Mersenne prime?

A Mersenne prime is a prime number written as 2^p - 1, where p is also prime. Not every prime exponent creates a Mersenne prime.

2. Why must the exponent be prime?

If p is composite, then 2^p - 1 factors into smaller integers. That makes the Mersenne candidate composite automatically, so the exponent must be prime first.

3. What does the Lucas–Lehmer test do?

It builds a residue sequence modulo the Mersenne candidate. When the final residue equals zero, the candidate passes the test and is prime.

4. Why can a prime exponent still fail?

Prime exponents are necessary, not sufficient. For example, p = 11 is prime, but 2^11 - 1 = 2047 is composite.

5. Why does the calculator mention GMP?

Large Mersenne numbers exceed normal integer limits. GMP lets PHP handle very large integers efficiently, which is essential for serious Mersenne testing.

6. What does the final residue mean?

The final residue is the Lucas–Lehmer sequence value after p - 2 steps. Zero means prime. Any nonzero value means the candidate is composite.

7. Can I enter the full Mersenne candidate directly?

Yes. The calculator can infer the exponent when the candidate matches the exact form 2^p - 1. Larger direct entries work best with GMP enabled.

8. What does the graph show?

The graph visualizes previewed Lucas–Lehmer residues across iterations. It helps you inspect sequence behavior, though plotted values may be shortened for display.

Related Calculators

Modular Exponentiation Fast Power CalculatorReverse Euclidean algorithm calculatorfast modular exponentiation calculatorLarge number modulo calculatormodular congruence solverpisano period calculatoreuler totient calculatorgcd calculatorprime number checkercommon multiples calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.