Mersenne Number Calculator
Generate and test a Mersenne number.
Result
How it is calculated
Enter the exponent p, a whole number from 2 to 1279. The tool computes M(p) = 2p − 1 in exact integer arithmetic and prints every digit with thousands separators; at p = 1279 that is 386 digits. The prime verdict is exact: it comes from the complete list of exponents up to 1279 that give a Mersenne prime (Lucas-Lehmer results): 2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607 and 1279. Every other exponent in range is reported as not prime, which includes every composite p, since 2p − 1 can only be prime when p is prime, and prime exponents such as 11, 23 or 67 that fail. A p below 2, above 1279 or with a fractional part shows no result.
Worked example
Let p = 11. Compute 211 = 2048, then subtract 1 to get 2,047. Eleven is prime, but it is not one of the exponents that yields a Mersenne prime, and indeed 2,047 = 23 × 89. The tool therefore shows 2,047 with the verdict Not prime. This is the classic case showing that a prime exponent does not guarantee a Mersenne prime. Try p = 13 for comparison: 213 − 1 = 8,191, which is prime. A larger case works too: p = 89 gives 618,970,019,642,690,137,449,562,111, which the tool marks as Prime.
Common mistakes
- Assuming every prime exponent gives a Mersenne prime. p = 11 gives 2,047 = 23 × 89, so it fails, and so does p = 67 (147,573,952,589,676,412,927 = 193,707,721 × 761,838,257,287).
- Entering the number you want to test instead of the exponent. Typing 2047 here is out of range; the field expects p, not 2p − 1.
- Forgetting the −1 and reading 2p as the Mersenne number. A power of two above 2 is never prime.
- Expecting results for very large exponents. The tool stops at p = 1279, so the record-sized Mersenne primes with exponents in the millions cannot be checked here and show nothing.
About this calculator
A Mersenne number has the form 2^p − 1 for a positive integer p, named after 17th-century friar and mathematician Marin Mersenne, who studied which of these numbers are prime. A Mersenne number can only be prime if the exponent p itself is prime, though that condition isn't sufficient on its own — 2^11 − 1 = 2047 = 23 × 89 is a counterexample despite 11 being prime. When a Mersenne number is prime, it's called a Mersenne prime, and it can be tested efficiently with the Lucas-Lehmer primality test, which is far faster than general-purpose primality testing for numbers of this size.
Mersenne primes are famous partly because they're the largest known primes ever discovered — the distributed computing project GIMPS (Great Internet Mersenne Prime Search) has found every record-holding prime since the 1990s by having volunteers' computers test candidate exponents around the clock. Beyond the hunt for record primes, Mersenne numbers show up in computer science because 2^p − 1 in binary is a run of p consecutive 1 bits, which makes them natural bit-masks, and each Mersenne prime corresponds to a perfect number via Euclid's formula.
This calculator computes 2^p − 1 for the exponent you enter and checks whether the result is prime.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
No calculators found
Comments (0)