Mersenne Prime Checker

Advanced Mersenne prime detection with Web Worker support, algorithm comparison, and detailed mathematical properties.

Web Worker: Ready

Mersenne Number Formula: Mp = 2p - 1

Advanced Features: Web Worker support for background computation, multiple algorithm comparison, and detailed mathematical properties.

Enter a positive integer (prime exponent recommended). Web Workers allow checking up to p = 50,000.
M₃ (7)
M₅ (31)
M₇ (127)
M₁₃ (8191)
M₁₇ (131071)
M₁₉ (524287)
M₃₁ (2.1B)
M₆₁ (2.3E18)
M₁₂₇ (1.7E38)
Web Worker prevents UI freezing during long computations
Control how much detail to show in results
Calculating...

Mersenne Prime Properties

Mathematical Definition:

A Mersenne number is a number of the form:

Mp = 2p - 1

If Mp is prime, then it is called a Mersenne prime.

Connection to Friendly (Amicable) Numbers

While not directly related to Mersenne primes, friendly numbers share interesting properties with perfect numbers (which are connected to Mersenne primes):

  • A pair of numbers (m, n) is called friendly if σ(m)/m = σ(n)/n, where σ is the sum of divisors function
  • Every even perfect number is friendly with itself (σ(n)/n = 2)
  • Mersenne primes generate perfect numbers: If 2p - 1 is prime, then 2p-1(2p - 1) is perfect
  • Perfect numbers are a special case of friendly number pairs (n, n)

Example: The perfect number 28 (from Mersenne prime 3) is friendly with itself: σ(28)/28 = 56/28 = 2

Known Mersenne Primes

As of 2023, only 51 Mersenne primes are known. The largest known prime number is almost always a Mersenne prime due to the efficiency of the Lucas-Lehmer test.

# Exponent p Mersenne Prime (Mp) Digits Year Discovered
1 2 3 1 Ancient
2 3 7 1 Ancient
3 5 31 2 Ancient
4 7 127 3 Ancient
5 13 8191 4 1456
6 17 131071 6 1588
7 19 524287 6 1588
8 31 2147483647 10 1772
9 61 2305843009213693951 19 1883
10 89 61897001964269013744... 27 1911
11 107 16225927682921336339... 33 1914
12 127 17014118346046923173... 39 1876
13 521 68647976601306097149... 157 1952
14 607 53113799281676709868... 183 1952
15 1279 10407932194664399081... 386 1952
16 2203 14759799152141802350... 664 1952
17 2281 44608755718375842957... 687 1952
18 3217 25911708601320262777... 969 1957
19 4253 19079700752443907380... 1281 1961
20 4423 28554254222827961390... 1332 1961
21 9689 47822027880546120295... 2917 1963
22 9941 34608828249085121524... 2993 1963
23 11213 28141120136973731333... 3376 1963
24 19937 43154247973881626480... 6002 1971
25 21701 44867916611904333479... 6533 1978

Algorithm Comparison

Algorithm Type Time Complexity Accuracy Best For
Lucas-Lehmer Deterministic O(p³ log p) 100% Mersenne numbers only
Miller-Rabin Probabilistic O(k log³ n) 1 - 4⁻ᵏ General numbers
AKS Deterministic Õ(log¹² n) 100% Theoretical interest
Trial Division Deterministic O(√n) 100% Small numbers

Web Worker Architecture

Benefits of Web Worker Implementation:

  • Non-blocking UI: Long computations run in background threads
  • Parallel processing: Multiple algorithms can run simultaneously
  • Better performance: Utilizes multiple CPU cores when available
  • Responsive interface: Users can interact with page during computation
  • Progress reporting: Real-time updates on computation progress

Historical Timeline of Mersenne Prime Discovery

Ancient Times

Euclid proves that if 2p - 1 is prime, then 2p-1(2p - 1) is a perfect number.

1644

Marin Mersenne studies numbers of the form 2p - 1 and conjectures about which values of p yield primes.

1750

Euler proves that all even perfect numbers have the form given by Euclid, establishing the connection between Mersenne primes and perfect numbers.

1876

Édouard Lucas develops the Lucas-Lehmer test, providing an efficient way to test Mersenne numbers for primality.

1996

Launch of the Great Internet Mersenne Prime Search (GIMPS), a distributed computing project that discovers many new Mersenne primes.

2023

51st Mersenne prime discovered: M82,589,933 = 282,589,933 - 1, with 24,862,048 digits.

Mathematical Properties of Mersenne Numbers

1

Binary Representation: Mp in binary is p consecutive 1's: 111...1112

2

Factor Form: Any factor of Mp must be of the form 2kp + 1

3

Perfect Numbers: Each Mersenne prime corresponds to an even perfect number: 2p-1(2p - 1)

4

Recurrence Relation: Mersenne numbers satisfy Mn+1 = 2Mn + 1

5

Sum of Powers: Mn = 1 + 2 + 4 + ... + 2n-1 (sum of geometric series)

Enhanced Calculator Features:

  • Web Worker support for non-blocking computation
  • Comparison of multiple primality testing algorithms
  • Performance analysis and benchmarking
  • Batch testing of multiple exponents
  • Historical context and mathematical properties
  • Connection to friendly numbers and other number theory concepts

Frequently Asked Questions

Mersenne primes are important because they have a simple form that makes them easier to test for primality than general numbers. They are connected to perfect numbers, and the search for them has driven the development of efficient primality testing algorithms and distributed computing projects like GIMPS.

As of December 2023, there are 51 known Mersenne primes. The largest known is M82589933 = 282589933 - 1, which has 24,862,048 digits. New Mersenne primes are discovered through the Great Internet Mersenne Prime Search (GIMPS) project.

No. If the exponent p is composite, then 2p - 1 is also composite. This is because if p = ab, then 2ab - 1 is divisible by 2a - 1 and 2b - 1.

The Lucas-Lehmer test has time complexity O(p3 log p) using naive multiplication algorithms, or O(p2 log p log log p) using fast Fourier transform multiplication. This makes it exponentially faster than general primality tests for numbers of the form 2p - 1.

The calculator runs in your web browser, which has limitations on memory and computation time. For very large exponents, the Mersenne numbers become enormous (millions of digits), which cannot be handled efficiently in JavaScript. For checking very large exponents, specialized software like Prime95 (used by GIMPS) is required.