If n is a composite number then so is 2n − 1. (2ab − 1 is divisible by both 2a − 1 and 2b − 1.) This definition is therefore equivalent to a definition as a prime number of the form Mp = 2p − 1 for some prime p.

More generally, numbers of the form Mn = 2n − 1 without the primality requirement may be called Mersenne numbers. Sometimes, however, Mersenne numbers are defined to have the additional requirement that n be prime.
The smallest composite Mersenne number with prime exponent n is 211 − 1 = 2047 = 23 × 89.

Many fundamental questions about Mersenne primes remain unresolved. It is not even known whether the set of Mersenne primes is finite or infinite. The Lenstra–Pomerance–Wagstaff conjecture asserts that there are infinitely many Mersenne primes and predicts their order of growth. It is also not known whether infinitely many Mersenne numbers with prime exponents are composite, although this would follow from widely believed conjectures about prime numbers, for example, the infinitude of Sophie Germain primescongruent to 3 (mod 4). For these primes p, 2p + 1 (which is also prime) will divide Mp, e.g., 23 | M11, 47 | M23, 167 | M83, 263 | M131, 359 | M179, 383 | M191, 479 | M239, and 503 | M251 (sequence A002515 in the OEIS). Since for these primes p, 2p + 1 is congruent to 7 mod 8, so 2 is a quadratic residue mod 2p + 1, and the multiplicative order of 2 mod 2p + 1 must divide (2p+1)−12{\displaystyle {\frac {(2p+1)-1}{2}}} = p. Since p is a prime, it must be p or 1. However, it cannot be 1 since Φ1(2)=1{\displaystyle \Phi _{1}(2)=1} and 1 has no prime factors, so it must be p. Hence, 2p + 1 divides Φp(2)=2p−1{\displaystyle \Phi _{p}(2)=2^{p}-1} and 2p − 1 = Mp cannot be prime.

The first four Mersenne primes are M2 = 3, M3 = 7, M5 = 31 and M7 = 127 and because the first Mersenne prime starts at M2, all Mersenne primes are congruent to 3 (mod 4). Other than M0 = 0 and M1 = 1, all other Mersenne numbers are also congruent to 3 (mod 4). Consequently, in the prime factorization of a Mersenne number ( ≥ M2 ) there must be at least one prime factor congruent to 3 (mod 4).

A basic theorem about Mersenne numbers states that if Mp is prime, then the exponent p must also be prime. This follows from the identity

Though the above examples might suggest that Mp is prime for all primes p, this is not the case, and the smallest counterexample is the Mersenne number

M11 = 211 − 1 = 2047 = 23 × 89.

The evidence at hand suggests that a randomly selected Mersenne number is much more likely to be prime than an arbitrary randomly selected odd integer of similar size.[citation needed] Nonetheless, prime values of Mp appear to grow increasingly sparse as p increases. For example, eight of the first 11 primes p give rise to a Mersenne prime Mp (the correct terms on Mersenne's original list), while Mp is prime for only 43 of the first two million prime numbers (up to 32,452,843).

The lack of any simple test to determine whether a given Mersenne number is prime makes the search for Mersenne primes a difficult task, since Mersenne numbers grow very rapidly. The Lucas–Lehmer primality test (LLT) is an efficient primality test that greatly aids this task, making it much easier to test the primality of Mersenne numbers than that of most other numbers of the same size. The search for the largest known prime has somewhat of a cult following. Consequently, a lot of computer power has been expended searching for new Mersenne primes, much of which is now done using distributed computing.

The first 64 prime exponents with those corresponding to Mersenne primes shaded in cyan and in bold, and those thought to do so by Mersenne in red and bold.

Mersenne primes take their name from the 17th-century French scholar Marin Mersenne, who compiled what was supposed to be a list of Mersenne primes with exponents up to 257. The exponents listed by Mersenne were as follows:

2, 3, 5, 7, 13, 17, 19, 31, 67, 127, 257.

His list replicated the known primes of his time with exponents up to 19. His next entry, 31, was correct, but the list then became largely incorrect, as Mersenne mistakenly included M67 and M257 (which are composite) and omitted M61, M89, and M107 (which are prime). Mersenne gave little indication how he came up with his list.[4]

Édouard Lucas proved in 1876 that M127 is indeed prime, as Mersenne claimed. This was the largest known prime number for 75 years, and the largest ever found by hand. M61 was determined to be prime in 1883 by Ivan Mikheevich Pervushin, though Mersenne claimed it was composite, and for this reason it is sometimes called Pervushin's number. This was the second-largest known prime number, and it remained so until 1911. Lucas had shown another error in Mersenne's list in 1876. Without finding a factor, Lucas demonstrated that M67 is actually composite. No factor was found until a famous talk by Frank Nelson Cole in 1903.[5] Without speaking a word, he went to a blackboard and raised 2 to the 67th power, then subtracted one. On the other side of the board, he multiplied 193,707,721 × 761,838,257,287 and got the same number, then returned to his seat (to applause) without speaking.[6] He later said that the result had taken him "three years of Sundays" to find.[7] A correct list of all Mersenne primes in this number range was completed and rigorously verified only about three centuries after Mersenne published his list.

The first four Mersenne primes M2 = 3, M3 = 7, M5 = 31 and M7 = 127 were known in antiquity. The fifth, M13 = 8191, was discovered anonymously before 1461; the next two (M17 and M19) were found by Pietro Cataldi in 1588. After nearly two centuries, M31 was verified to be prime by Leonhard Euler in 1772. The next (in historical, not numerical order) was M127, found by Édouard Lucas in 1876, then M61 by Ivan Mikheevich Pervushin in 1883. Two more (M89 and M107) were found early in the 20th century, by R. E. Powers in 1911 and 1914, respectively.

The best method presently known for testing the primality of Mersenne numbers is the Lucas–Lehmer primality test. Specifically, it can be shown that for prime p > 2, Mp = 2p − 1 is prime if and only ifMp divides Sp − 2, where S0 = 4 and Sk = (Sk − 1)2 − 2 for k > 0.

During the era of manual calculation, all the exponents up to and including 257 were tested with the Lucas–Lehmer test and found to be composite. A notable contribution was made by retired Yale physics professor Horace Scudder Uhler, who did the calculations for exponents 157, 167, 193, 199, 227, and 229.[8] Unfortunately for those investigators, the interval they were testing contains the largest known gap between Mersenne primes, in relative terms: the next Mersenne prime exponent, 521, would turn out to be more than four times larger than the previous record of 127.

Graph of number of digits in largest known Mersenne prime by year – electronic era. Note that the vertical scale, the number of digits, is doubly logarithmic in the value of the prime.

The search for Mersenne primes was revolutionized by the introduction of the electronic digital computer. Alan Turing searched for them on the Manchester Mark 1 in 1949,[9] but the first successful identification of a Mersenne prime, M521, by this means was achieved at 10:00 pm on January 30, 1952 using the U.S. National Bureau of StandardsWestern Automatic Computer (SWAC) at the Institute for Numerical Analysis at the University of California, Los Angeles, under the direction of Lehmer, with a computer search program written and run by Prof. R. M. Robinson. It was the first Mersenne prime to be identified in thirty-eight years; the next one, M607, was found by the computer a little less than two hours later. Three more — M1279, M2203, M2281 — were found by the same program in the next several months. M4253 is the first Mersenne prime that is titanic, M44,497 is the first gigantic, and M6,972,593 was the first megaprime to be discovered, being a prime with at least 1,000,000 digits.[10] All three were the first known prime of any kind of that size. The number of digits in the decimal representation of Mn equals ⌊n × log102⌋ + 1, where ⌊x⌋ denotes the floor function (or equivalently ⌊log10Mn⌋ + 1).

In September 2008, mathematicians at UCLA participating in GIMPS won part of a $100,000 prize from the Electronic Frontier Foundation for their discovery of a very nearly 13-million-digit Mersenne prime. The prize, finally confirmed in October 2009, is for the first known prime with at least 10 million digits. The prime was found on a Dell OptiPlex 745 on August 23, 2008. This was the eighth Mersenne prime discovered at UCLA.[11]

On April 12, 2009, a GIMPS server log reported that a 47th Mersenne prime had possibly been found. The find was verified on June 12, 2009. The prime is 242,643,801 − 1. Although it is chronologically the 47th Mersenne prime to be discovered, it is smaller than the largest known at the time, which was the 45th to be discovered.

On January 25, 2013, Curtis Cooper, a mathematician at the University of Central Missouri, discovered a 48th Mersenne prime, 257,885,161 − 1 (a number with 17,425,170 digits), as a result of a search executed by a GIMPS server network.[12]

On January 19, 2016, Cooper published his discovery of a 49th Mersenne prime, 274,207,281 − 1 (a number with 22,338,618 digits), as a result of a search executed by a GIMPS server network.[13][14][15] This was the fourth Mersenne prime discovered by Cooper and his team in the past ten years.

On January 3, 2018, it was announced that Jonathan Pace, a 51-year-old electrical engineer living in Germantown, Tennessee, had found a 50th Mersenne prime, 277,232,917 − 1 (a number with 23,249,425 digits), as a result of a search executed by a GIMPS server network.[16]

Proof: By Fermat's little theorem, q is a factor of 2q − 1 − 1. Since q is a factor of 2p − 1, for all positive integers c, q is also a factor of 2pc − 1. Since p is prime and q is not a factor of 21 − 1, p is also the smallest positive integer x such that q is a factor of 2x − 1. As a result, for all positive integers x, q is a factor of 2x − 1 if and only if p is a factor of x. Therefore, since q is a factor of 2q − 1 − 1, p is a factor of q − 1 so q ≡ 1 (mod p). Furthermore, since q is a factor of 2p − 1, which is odd, q is odd. Therefore, q ≡ 1 (mod 2p).

This fact leads to a proof of Euclid's theorem, which asserts the infinitude of primes, distinct from the proof written by Euclid: for every odd prime p, all primes dividing 2p − 1 are larger than p; thus there are always larger primes than any particular prime.

This fact also implies that for every prime p > 2, there is at least one prime of the form 2kp+1 less than or equal to Mp, for some integer k.

If p is an odd prime, then every prime q that divides 2p − 1 is congruent to ±1 (mod 8).

Proof: 2p + 1 ≡ 2 (mod q), so 21/2(p + 1) is a square root of 2 mod q. By quadratic reciprocity, every prime modulo in which the number 2 has a square root is congruent to ±1 (mod 8).

If m and n are natural numbers then m and n are coprime if and only if 2m − 1 and 2n − 1 are coprime. Consequently, a prime number divides at most one prime-exponent Mersenne number,[17] so in other words the set of pernicious Mersenne numbers is pairwise coprime.

Proof: Let q be 2p + 1. By Fermat's little theorem, 22p ≡ 1 (mod q), so either 2p ≡ 1 (mod q) or 2p ≡ −1 (mod q). Supposing latter true, then 2p + 1 = (21/2(p + 1))2 ≡ −2 (mod q), so −2 would be a quadratic residue mod q. However, since p is congruent to 3 (mod 4), q is congruent to 7 (mod 8) and therefore 2 is a quadratic residue mod q. Also since q is congruent to 3 (mod 4), −1 is a quadratic nonresidue mod q, so −2 is the product of a residue and a nonresidue and hence it is a nonresidue, which is a contradiction. Hence, the former congruence must be true and 2p + 1 divides Mp.

All composite divisors of prime-exponent Mersenne numbers are strong pseudoprimes to the base 2.

^ abcIt is not verified whether any undiscovered Mersenne primes exist between the 47th (M43,112,609) and the 50th (M77,232,917) on this chart; the ranking is therefore provisional.

^M74,207,281 was first found by a machine on September 17, 2015; however, no human took notice of this fact until January 7, 2016. Thus, either date may be considered the 'discovery' date. GIMPS considers the January 2016 date to be the official one.

All Mersenne numbers below the 50th Mersenne prime (M77,232,917) have been tested at least once but some have not been double-checked. Primes are not always discovered in increasing order. For example, the 29th Mersenne prime was discovered after the 30th and the 31st. Similarly, M43,112,609 was followed by two smaller Mersenne primes, first 2 weeks later and then 8 months later.[75]M43,112,609 was the first discovered prime number with more than 10 million decimal digits.

Since they are prime numbers, Mersenne primes are divisible only by 1 and by themselves. However, not all Mersenne numbers are Mersenne primes, and the composite Mersenne numbers may be factored nontrivially. Mersenne numbers are very good test cases for the special number field sieve algorithm, so often the largest number factorized with this algorithm has been a Mersenne number. As of August 2016[update], 21,193 − 1 is the record-holder,[77] having been factored with a variant of the special number field sieve that allows the factorization of several numbers at once. See integer factorization records for links to more information. The special number field sieve can factorize numbers with more than one large factor. If a number has only one very large factor then other algorithms can factorize larger numbers by first finding small factors and then making a primality test on the cofactor. As of March 2018[update], the largest factorization with probable prime factors allowed is 27,313,983 − 1 = 305,492,080,276,193 × q, where q is a 2,201,714-digit probable prime. It was discovered by Oliver Kruse.[78] As of June 2018[update], the Mersenne number M1277 is the smallest composite Mersenne number with no known factors; it has no prime factors below 267.[79]

The table below shows factorizations for the first 20 composite Mersenne numbers (sequence A244453 in the OEIS).

Besides, if we notice those prime factors, and delete "old prime factors", for example, 3 divides the 2nd, 6th, 18th, 54th, 162nd, ... terms of this sequence, we only allow the 2nd term divided by 3, if we do, they are

In geometry, an integer right triangle that is primitive and has its even leg a power of 2 ( ≥ 4 ) generates a unique right triangle such that its inradius is always a Mersenne number. For example if the even leg is 2n + 1 then because it is primitive it constrains the odd leg to be 4n − 1, the hypotenuse to be 4n + 1 and its inradius to be 2n − 1.[82]

A Mersenne–Fermat number is defined as 2pr − 1/2pr − 1 − 1, with p prime, r natural number, and can be written as MF(p, r), when r = 1, it is a Mersenne number, and when p = 2, it is a Fermat number, the only known Mersenne–Fermat prime with r > 1 are

The simplest generalized Mersenne primes are prime numbers of the form f(2n), where f(x) is a low-degree polynomial with small integer coefficients.[84] An example is 264 − 232 + 1, in this case, n = 32, and f(x) = x2 − x + 1; another example is 2192 − 264 − 1, in this case, n = 64, and f(x) = x3 − x − 1.

It is also natural to try to generalize primes of the form 2n − 1 to primes of the form bn − 1 (for b ≠ 2 and n > 1). However (see also theorems above), bn − 1 is always divisible by b − 1, so unless the latter is a unit, the former is not a prime. There are two ways to deal with that:

If we regard the ring of Gaussian integers, we get the case b = 1 + i and b = 1 − i, and can ask (WLOG) for what n the number (1 + i)n − 1 is a Gaussian prime which will then be called a Gaussian Mersenne prime.[85]

We can also regard the ring of Eisenstein integers, we get the case b = 1 + ω and b = 1 − ω, and can ask for what n the number (1 + ω)n − 1 is an Eisenstein prime which will then be called a Eisenstein Mersenne prime.

It is a conjecture that for every integer b which is not a perfect power, there are infinitely many values of n such that bn − 1/b − 1 is prime. (When b is a perfect power, it can be shown that there is at most one n value such that bn − 1/b − 1 is prime)

Least n such that bn − 1/b − 1 is prime are (starting with b = 2, 0 if no such n exists)

with a, b any coprime integers, a > 1 and −a < b < a. (Since an − bn is always divisible by a − b, the division is necessary for there to be any chance of finding prime numbers. In fact, this number is the same as the Lucas numberUn(a + b, ab), since a and b are the roots of the quadratic equationx2 − (a + b)x + ab = 0, and this number equals 1 when n = 1) We can ask which n makes this number prime. It can be shown that such n must be primes themselves or equal to 4, and n can be 4 if and only if a + b = 1 and a2 + b2 is prime. (Since a4 − b4/a − b = (a + b)(a2 + b2). Thus, in this case the pair (a, b) must be (x + 1, −x) and x2 + (x + 1)2 must be prime. That is, x must be in OEIS: A027861.) It is a conjecture that for any pair (a, b) such that for every natural number r > 1, a and b are not both perfect rth powers, and −4ab is not a perfect fourth power. there are infinitely many values of n such that an − bn/a − b is prime. (When a and b are both perfect rth powers for an r > 1 or when −4ab is a perfect fourth power, it can be shown that there are at most two n values with this property, since if so, then an − bn/a − b can be factored algebraically) However, this has not been proved for any single value of (a, b).

*Note: if b < 0 and n is even, then the numbers n are not included in the corresponding OEIS sequence.

A conjecture related to the generalized Mersenne primes:[96][97] (the conjecture predicts where is the next generalized Mersenne prime, if the conjecture is true, then there are infinitely many primes for all such (a,b) pairs)

For every natural number r > 1, a and b are not both perfect rth powers. (since when a and b are both perfect rth powers, it can be shown that there are at most two n value such that an − bn/a − b is prime, and these n values are r itself or a root of r, or 2)

^ abThere is no mentioning among the ancient Egyptians of prime numbers, and they did not have any concept for prime numbers known today. In the Rhind papyrus (1650 BC) the Egyptian fraction expansions have fairly different forms for primes and composites, so it may be argued that they knew about prime numbers. "The Egyptians used ($) in the table above for the first primes r = 3, 5, 7, or 11 (also for r = 23). Here is another intriguing observation: That the Egyptians stopped the use of ($) at 11 suggests they understood (at least some parts of) Eratosthenes's Sieve 2000 years before Eratosthenes 'discovered' it." The Rhind 2/n Table [Retrieved 2012-11-11].
In the school of Pythagoras (b. about 570 – d. about 495 BC) and the Pythagoreans, we find the first sure observations of prime numbers. Hence the first two Mersenne primes, 3 and 7, were known to and may even be said to have been discovered by them. There is no reference, though, to their special form 22 − 1 and 23 − 1 as such.
The sources to the knowledge of prime numbers among the Pythagoreans are late. The Neoplatonic philosopher Iamblichus, AD c. 245–c. 325, states that the Greek Platonic philosopher Speusippus, c. 408 – 339/8 BC, wrote a book named On Pythagorean Numbers. According to Iamblichus this book was based on the works of the Pythagorean Philolaus, c. 470–c. 385 BC, who lived a century after Pythagoras, 570 – c. 495 BC. In his Theology of Arithmetic in the chapter On the Decad, Iamblichus writes: "Speusippus, the son of Plato's sister Potone, and head of the Academy before Xenocrates, compiled a polished little book from the Pythagorean writings which were particularly valued at any time, and especially from the writings of Philolaus; he entitled the book On Pythagorean Numbers. In the first half of the book, he elegantly expounds linear numbers [i.e. prime numbers], polygonal numbers and all sorts of plane numbers, solid numbers and the five figures which are assigned to the elements of the universe, discussing both their individual attributes and their shared features, and their proportionality and reciprocity." Iamblichus The Theology of Arithmetic translated by Robin Waterfiled, 1988, p. 112f. [Retrieved 2012-11-11].
Iamblichus also gives us a direct quote from Speusippus' book where Speusippus among other things writes: "Secondly, it is necessary for a perfect number [the concept "perfect number" is not used here in a modern sense] to contain an equal amount of prime and incomposite numbers, and secondary and composite numbers." Iamblichus The Theology of Arithmetic translated by Robin Waterfiled, 1988, p. 113. [Retrieved 2012-11-11]. For the Greek original text, see Speusippus of Athens: A Critical Study with a Collection of the Related Texts and Commentary by Leonardo Tarán, 1981, p. 140 line 21–22 [Retrieved 2012-11-11]
In his comments to Nicomachus of Gerasas's Introduction to Arithmetic, Iamblichus also mentions that Thymaridas, ca. 400 BC – ca. 350 BC, uses the term rectilinear for prime numbers, and that Theon of Smyrna, fl. AD 100, uses euthymetric and linear as alternative terms. Nicomachus of Gerasa, Introduction to Arithmetic, 1926, p. 127 [Retrieved 2012-11-11] It is unclear though when this said Thymaridas lived. "In a highly suspect passage in Iamblichus, Thymaridas is listed as a pupil of Pythagoras himself." Pythagoreanism [Retrieved 2012-11-11]
Before Philolaus, c. 470–c. 385 BC, we have no proof of any knowledge of prime numbers.

^We find the oldest (undisputed) note of the result in Codex nr. 14908, which origins from Bibliotheca monasterii ord. S. Benedicti ad S. Emmeramum Ratisbonensis now in the archive of the Bayerische Staatsbibliothek, see "Halm, Karl / Laubmann, Georg von / Meyer, Wilhelm: Catalogus codicum latinorum Bibliothecae Regiae Monacensis, Bd.: 2,2, Monachii, 1876, p. 250". [retrieved on 2012-09-17] The Codex nr. 14908 consists of 10 different medieval works on mathematics and related subjects. The authors of most of these writings are known. Some authors consider the monk Fridericus Gerhart (Amman), 1400–1465 (Frater Fridericus Gerhart monachus ordinis sancti Benedicti astrologus professus in monasterio sancti Emmerani diocesis Ratisponensis et in ciuitate eiusdem) to be the author of the part where the prime number 8191 is mentioned. Geschichte Der Mathematik [retrieved on 2012-09-17] The second manuscript of Codex nr. 14908 has the name "Regulae et exempla arithmetica, algebraica, geometrica" and the 5th perfect number and all is factors, including 8191, are mentioned on folio no. 34 a tergo (backside of p. 34). Parts of the manuscript have been published in Archiv der Mathematik und Physik, 13 (1895), pp. 388–406 [retrieved on 2012-09-23]

^"On the evening of March 4, 1971, a zero Lucas-Lehmer residue for p = p24 = 19937 was found. Hence, M19937 is the 24th Mersenne prime." Bryant Tuckerman, The 24th Mersenne Prime, Proceedings of the National Academy of Sciences of the United States of America, vol. 68:10 (1971), pp. 2319–2320, http://www.pnas.org/content/68/10/2319.full.pdf [Retrieved 2012-09-18]

^"The 27th Mersenne prime. It has 13395 digits and equals 244497 – 1. [...] Its primeness was determined on April 8, 1979 using the Lucas–Lehmer test. The test was programmed on a CRAY-1 computer by David Slowinski & Harry Nelson." (p. 15) "The result was that after applying the Lucas–Lehmer test to about a thousand numbers, the code determined, on Sunday, April 8th, that 244497 − 1 is, in fact, the 27th Mersenne prime." (p. 17), David Slowinski, "Searching for the 27th Mersenne Prime", Cray Channels, vol. 4, no. 1, (1982), pp. 15–17.

^"On April 12th [2009], the 47th known Mersenne prime, 242,643,801 – 1, a 12,837,064 digit number was found by Odd Magnar Strindmo from Melhus, Norway! This prime is the second largest known prime number, a "mere" 141,125 digits smaller than the Mersenne prime found last August.", The List of Largest Known Primes Home Page, http://primes.utm.edu/primes/page.php?id=88847 [retrieved 2012-09-18]