Mersenne Number Calculator
This Mersenne number calculator works out 2 to the power p, minus 1, for any exponent p you enter, along with two facts that matter in number theory: how many digits the result has and whether p itself is prime. You type in a whole number exponent between 1 and 5000, and the calculator uses exact integer arithmetic to return the full Mersenne number grouped with commas for readability, its digit count, and a yes or no on whether p is prime. This matters because a Mersenne number can only be prime if its exponent is prime; a composite p guarantees the result factors, though a prime p is no guarantee either, since many prime exponents still produce composite Mersenne numbers. Mersenne numbers, named after the French friar Marin Mersenne, sit at the heart of the hunt for record-breaking primes, because an efficient test called Lucas-Lehmer makes checking them for primality far quicker than testing ordinary numbers of similar size, which is why nearly every largest known prime found by the GIMPS project has been a Mersenne prime. Try the default value of 7 for the worked example: 2 to the 7 minus 1 equals 127, a genuine Mersenne prime, then try 11 to see 2047, which factors as 23 times 89. This tool suits students, programmers and anyone curious about number theory, not anyone needing a financial estimate.
The formula
The Mersenne number for exponent p is M_p = 2^p minus 1. If M_p is prime it is a Mersenne prime, and a Mersenne prime requires p to be prime (but a prime p does not guarantee one).
Worked example
For p = 7, M_7 = 2^7 minus 1 = 128 minus 1 = 127, which is prime, so 127 is a Mersenne prime. For p = 11, M_11 = 2047 = 23 times 89, not prime. Enter 7 to confirm.
Frequently asked questions
What is a Mersenne number?
A number of the form 2 to the power p, minus 1. When it is also prime it is called a Mersenne prime.
Why must p be prime?
If p is composite then 2^p minus 1 factors, so it cannot be prime. A prime p is necessary but not sufficient.
Why are the largest known primes Mersenne primes?
There is a very efficient primality test (Lucas-Lehmer) for Mersenne numbers, which makes searching them practical.
Who this calculator is for
This calculator is for students, programmers and anyone exploring number theory.
What this calculator assumes
- You enter a whole number within the stated range.
- The exact integer algorithm is used.
- Very large results are shown grouped for readability.
Formula and sources
Related calculators
- Prime Factorization Calculator: break a number into prime factors.
- LCM Calculator: lowest common multiple.
- GCF Calculator: greatest common factor.