Mersenne Prime Checker screenshot

Mersenne Prime Checker

Test 2^p - 1 for primality with BigInt Miller-Rabin, up to p = 521, and say whether the exponent itself is prime.

Privacy First
0 Runs
Updated 2026-11-22
No upload
Instant
No signup

Mersenne Prime Checker

Test 2^p - 1 for primality with BigInt Miller-Rabin, up to p = 521, and say whether the exponent itself is prime.

How this page computes

The primality test is deterministic Miller-Rabin below 3.3 times 10 to the 24 and a strong probable-prime test above it, over the first twelve prime bases. The exponent is capped at 521, where the candidate is still a single BigInt.

The calculation runs entirely in this browser tab; nothing is uploaded.

The page computes 2^p minus 1 exactly and tests it for primality. When the exponent is not prime the candidate is composite by construction, and the page says so without running the test.

Worked example: p = 7 gives 127, which is prime. p = 11 gives 2047, which is composite even though 11 is prime. Above 3.3 times 10 to the 24 the test is a strong probable-prime test over twelve bases, and the page labels it that way rather than claiming a proof.

How to use the Mersenne Prime Checker

Enter the exponent p as a whole number and press Run. The page prints the candidate, its primality verdict and its digit count.

The verdict line distinguishes three cases: the exponent is composite, the candidate is composite, or the candidate is prime. A huge candidate is printed in full, so the digit count and the value can be checked against each other.

The rule this page applies

A Mersenne number is 2^p minus 1. If p is composite then 2^p minus 1 factors, so only prime exponents can produce a Mersenne prime; the page checks the exponent first for that reason.

The primality test is deterministic Miller-Rabin below 3.3 times 10 to the 24 and a strong probable-prime test above it, over the first twelve prime bases. The exponent is capped at 521, where the candidate is still a single BigInt.

What to Expect

Best for

  • Checking a Mersenne prime claim
  • Seeing why a prime exponent can still give a composite
  • Working with a very large integer exactly

Not ideal for

  • Proving primality for a candidate above the deterministic range
  • Exponents above 521
  • Searching for the next Mersenne prime

What this tool keeps

  • The exact candidate value and its digit count

What may need cleanup

  • Nothing: the candidate and the verdict are final

Common errors

  • A composite exponent is reported as composite by construction, not tested
  • An exponent above 521 is refused with the ceiling named

Example use cases

  • Check p = 7, where 2^7 - 1 is 127
  • See p = 11 produce the composite 2047

Sample input

7

Sample output

p = 7: 2^7 - 1 = 127 the candidate is prime (proved by a deterministic Miller-Rabin test) digits: 3

Who this is for

  • Students meeting Mersenne primes
  • Readers checking a large-number claim

Frequently asked questions

Why must the exponent be prime?

If p equals a times b with both factors greater than one, then 2^p minus 1 factors as well. A composite exponent therefore cannot give a Mersenne prime, and the page reports that case without a primality test.

Is a probable prime the same as a prime?

For candidates below 3.3 times 10 to the 24 the twelve-base Miller-Rabin test is deterministic, so the answer is a proof. Above that the page says strong probable prime, because the same twelve bases no longer constitute a proof.

Why stop at 521?

2^521 minus 1 is about 157 digits and still fits comfortably in one BigInt, while the printed value stays readable. A larger cap would print a wall of digits without teaching anything more.

Is anything uploaded?

Nothing is uploaded. The numbers are read and the arithmetic runs in this browser tab with JavaScript, and reloading the page discards both the input and the result.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.