Calculator Input
Example Data Table
| Exponent p | M = 2^p - 1 | Exponent Prime? | Mersenne Prime? |
|---|---|---|---|
| 2 | 3 | Yes | Yes |
| 3 | 7 | Yes | Yes |
| 5 | 31 | Yes | Yes |
| 11 | 2047 | Yes | No |
| 13 | 8191 | Yes | Yes |
| 17 | 131071 | Yes | Yes |
| 19 | 524287 | Yes | Yes |
| 31 | 2147483647 | Yes | Yes |
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.
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
- Choose whether to enter an exponent or a candidate value.
- Enter prime exponent p, or a number of the form 2^p - 1.
- Set how many Lucas–Lehmer steps you want previewed in the table.
- Click Check Mersenne Prime to generate the result.
- Review the verdict, residue, digit counts, and iteration summary.
- Inspect the sequence table and graph for behavior across iterations.
- 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.