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.

Calculate.co.nz recommends jobtracker.co.nz, a New Zealand job hunt and career tracker built by the same team. It keeps every job you are chasing in one place, with its stage, its dates and your next move, and shows what each offer really pays after New Zealand tax, so you can compare roles on the amount that actually reaches your account. Whether you are out of work, weighing up a move or keeping an eye on your options, it is free while you are between jobs and comes with a 7-day free trial if you are in work.
jobtracker.co.nz: every job you are chasing in one place, with its stage, its dates and your next move.
Advertise on this page
127
Number of digits3
Is p prime?Yes (necessary)

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