In this section we investigate the primes of the form2๐+ 1and2๐โ 1; they are called FermatandMersenneprimes, respectively. As mentioned in the previous section, it is unknown whether or not there exist infinitely many Fermat or Mersenne primes.
In Exercise 1.4.4 we have seen that if2๐+1is a prime, then๐is necessarily a power of two, whereas if2๐โ 1is a prime, then๐itself must be a prime. Thus it is enough to investigate the Fermat numbers๐น๐= 22๐+ 1and the Mersenne numbers๐๐= 2๐โ 1 (where๐is a prime).
We consider Fermat numbers first. Fermat believed that๐น๐was always a prime (this isnotthe famous Fermatโs Last Theorem to be discussed in Chapter 7). For0 โค ๐ โค 4these are primes (3,5,17,257, and65537), but Euler showed that๐น5= 232+ 1is composite, since it is divisible by641.
As of February 2019 we know that๐น๐is composite for5 โค ๐ โค 32and also for some larger values of๐. The record is๐น3329780 (with more than101000000decimal digits!) having a factor193 โ 23329782+ 1. No other Fermat primes have been found other than the๐น๐ with๐ โค 4. We have no information about๐น33. No factors of๐น20or ๐น24 are known (though they are known to be composite). The factorization of๐น5,๐น6, and๐น7
can be found in the table of Fermat numbers at the end of this book (the complete factorization of๐น๐is known only for๐ โค 11).
The Fermat primes play a central role in the Euclidean constructibility of regular polygons: Gaussโs theorem states that a regular๐-gon is constructible if and only if the standard form of๐, ๐ โฅ 3is๐ = 2๐ผ๐1. . . ๐๐where๐ผ โฅ 0,๐ โฅ 0, and the numbers๐๐
are distinct Fermat primes. The first few values are๐ = 3,4,5,6,8,10,12,15,16,17, 20, . . . .
5.2. Fermat and Mersenne Primes 119
The following two theorems give practical tools for investigating the Fermat num- bers. Theorem 5.2.1 is an effective help in finding their prime divisors and Theo- rem 5.2.2 yields a (relatively) fast algorithm to test whether a given Fermat number is prime or composite.
Theorem 5.2.1. Any (positive) divisor of๐น๐is of the form๐2๐+1+ 1, and for๐ โฅ 2it is
of the form๐2๐+2+ 1. โฃ
Presumably Euler used this theorem for proving that๐น5 is composite: the prime divisors of๐น5can only be primes of form128๐ + 1. The first two of these are257and 641, and the latter one divides๐น5.
Proof. First we verify the statement if the divisor is a prime๐. Then๐ โฃ ๐น๐means
(5.2.1) 22๐โก โ1 (mod ๐) .
Squaring both sides, we obtain
(5.2.2) 22๐+1โก 1 (mod ๐) .
By Theorem 3.2.2(i),
2๐โก 1 (mod ๐) โบ ๐๐(2) โฃ ๐.
Hence (5.2.2) implies
๐๐(2) โฃ 2๐+1, and by (5.2.1), we have
๐๐(2) โค 2๐,
since clearly๐ > 2, and thusโ1 โข 1 (mod ๐). It follows that ๐๐(2) = 2๐+1.
Using๐๐(2) โฃ ๐ โ 1, we obtain2๐+1โฃ ๐ โ 1, so๐ = ๐2๐+1+ 1for a suitable integer๐.
If๐ โฅ 2, then this implies๐ = 8๐ + 1, so (2
๐) = 1, hence 2๐โ12 โก 1 (mod ๐) . Therefore
๐๐(2) = 2๐+1|
| ๐ โ 1 2 , so๐ = ๐2๐+2+ 1for a suitable integer๐.
These results can be written also as๐ โก 1 (mod 2๐+1), and for๐ โฅ 2, as๐ โก 1 (mod 2๐+2).
Consider an arbitrary divisor๐ โฃ ๐น๐. Write๐ as the product of (not necessarily distinct) primes (if๐ > 1):๐ = ๐1. . . ๐๐ . We have just proven that๐๐ โก 1 (mod 2๐+1) for every๐. Multiplying these congruences, we see that also๐ โก 1 (mod 2๐+1)holds.
We can use the same argument also for the modulus2๐+2. โก Theorem 5.2.2(Pepinโs test). Let๐ โฅ 1. Then๐น๐is prime if and only if
โฃ (5.2.3) 3(๐น๐โ1)/2โก โ1 (mod ๐น๐) .
Proof. Assume first that๐น๐is a prime. Then (5.2.3) means that3is a quadratic non- residue modulo๐น๐, i.e.
(3 ๐น๐
) = โ1.
To verify this, we use that๐ โฅ 1yields22๐ = 4๐ก, hence
๐น๐โก 1 (mod 4) , and ๐น๐= 4๐ก+ 1 โก โ1 (mod 3) . Applying quadratic reciprocity, we obtain
(3
๐น๐) = (๐น๐
3 ) = (โ1 3 ) = โ1.
To prove the converse, assume that (5.2.3) holds. Squaring both sides, we get
(5.2.4) 3๐น๐โ1โก 1 (mod ๐น๐) .
Congruences (5.2.4) and (5.2.3) imply
๐๐น๐(3) โฃ ๐น๐โ 1 and ๐๐น๐(3) โค ๐น๐โ 1 2 . Since๐น๐โ 1is a power of two, we infer
๐๐น๐(3) = ๐น๐โ 1.
Therefore๐น๐โ 1 โฃ ๐(๐น๐)follows. Clearly๐(๐น๐) โค ๐น๐โ 1, therefore๐น๐โ 1 = ๐(๐น๐), or
equivalently,๐น๐is a prime. โก
Using Theorem 5.2.2, we can show the compositeness of๐น5= 232+1by computing the residue of3231 modulo๐น5 by31squarings and reducing modulo๐น5in every step.
It turns out that this residue is notโ1. Moreover, even Fermatโs Little Theorem is sufficient for our purposes:32such steps of squaring and reduction reveal
3๐น5โ1= 3232โข 1 (mod ๐น5) ,
hence๐น5 cannot be a prime. So Fermat could have disproved his conjecture about Fermat primes with his own theorem (the computations would have been no obstacle since even more lengthy calculations were regularly done in those times).
Theorem 5.2.2 is an efficient tool in general for determining whether a Fermat number is prime or composite: we can check the validity of (5.2.3) quickly by repeated squarings (and reducing modulo๐น๐); we need altogether2๐โ1 โ log2๐น๐such steps.
Unfortunately, the practical application is limited by the fact that the Fermat numbers grow with enormous speed,๐น๐โ ๐น๐โ12 , therefore computers are unable to handle even relatively small values of๐.
Now we turn to study the Mersenne numbers๐๐ = 2๐โ 1(where๐is a prime). It is easy to see that not all of them are primes; the smallest composite number is obtained for๐ = 11:
211โ 1 = 2047 = 23 โ 89.
The significance of Mersenne primes lies, partly, in their connection with the even perfect numbers (see Theorem 6.3.2). Mersenne was a superb scientific manager in the seventeenth century, corresponding intensively with Fermat, Descartes, and other
5.2. Fermat and Mersenne Primes 121
leading scientists, and encouraged the search for such primes in the hope of finding new perfect numbers.
Mersenne was aware of the difficulty of determining whether a large integer is prime or composite. He wrote in his book in 1644: โTo tell if a given number of15or 20digits is prime or not, all time would not suffice for the test, whatever use is made of what is already known.โ A few pages later, however, we can read his claim that:2๐โ 1 is a prime for๐ = 2,3,5,7,13,17,19,31,67,127,257, but for no other values of๐ below 257.
For more than two centuries, nobody knew whether Mersenneโs list was correct or not. The first error was discovered in 1876(!) by another Frenchman, รdouard Lucas, who proved that267โ 1is composite. It is interesting that Lucas proved the compos- iteness of267โ 1without exhibiting any factors of it (based on Theorem 5.2.4 bearing also his name). The factorization
193707721 โ 761838257287
was found only in 1903(!) by the American mathematician F. N. Cole who spent three years of Sunday afternoons wrestling with the problem (remember, he had to work by hand without computers, since these were invented half a century later).
Later four other errors were discovered in Mersenneโs list: the missing261 โ 1, 289โ 1, and2107โ 1are primes and2257โ 1is composite.
The presently (as of February 2019) known51Mersenne primes are2๐โ 1where ๐ = 2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279,2203,2281,3217,4253, 4423,9689,9941,11213,19937,21701,23209,44497,86243,110503,132049,216091, 756839,859433,1257787,1398269,2976221,3021377,6972593,13466917,20996011, 24036583,25964951,30402457,32582657,37156667,42643801,43112609,57885161, 74207281,77232917, and82589933. The last number,282589933โ 1is the largest known primeโit has24862048decimal digits! It is a famous unsolved problem whether there are infinitely many Mersenne primes.
In the table of Mersenne numbers at the end of this book you can find the prime factorization of all composite Mersenne numbers for the (prime) exponents between 10and100.
Now we prove the analogues of Theorems 5.2.1 and 5.2.2 for Mersenne numbers.
Theorem 5.2.3. Let๐ > 2be a prime. Then any (positive) divisor of๐๐ = 2๐โ 1is of
the forms2๐๐ + 1and8๐ ยฑ 1. โฃ
Example. Consider๐ = 47. Then for any prime divisor๐of๐47 = 247โ 1, we have ๐ = 94๐ + 1 = 8๐ ยฑ 1. Solving the system of simultaneous congruences
๐ฅ โก 1 (mod 94) , ๐ฅ โก ยฑ1 (mod 8) we obtain
๐ฅ โก 1or95 (mod 376) . The primes satisfying these conditions are
๐ = 1129, 1223, 2351, . . . We find that2351 โฃ ๐47, hence๐47is composite.
It is conceivable that also Mersenne found this divisor of๐47, and therefore he did not include๐ = 47into his list (and the missing of this value is not just a lucky coincidence).
Proof. Similar to the argument seen at the Fermat numbers, it is sufficient to prove the statement for prime divisors.
Assume that a prime๐satisfies
๐ โฃ 2๐โ 1, i.e. 2๐โก 1 (mod ๐) . Then๐๐(2) โฃ ๐, and๐๐(2) โ 1, hence๐๐(2) = ๐.
We infer๐ โฃ ๐ โ 1, thus๐ = ๐ก๐ + 1. Since๐and๐are odd, therefore๐กis even, so ๐ = 2๐๐ + 1.
To verify๐ = 8๐ ยฑ 1, we have to show that2is a quadratic residue mod๐. This follows from the congruence2๐โก 1 (mod ๐)by the properties of the Legendre symbol using that๐is odd:
(2 ๐) = (2
๐)
๐
= (2๐ ๐) = (1
๐) = 1. โก
Theorem 5.2.4(LucasโLehmer-test). Let๐ > 2be a prime,๐1= 4, and๐๐+1= ๐2๐ โ 2 for๐ โฅ 1. Then๐๐is a prime if and only if
โฃ
(5.2.5) ๐๐โฃ ๐๐โ1.
Example. Put๐ = 5. Then
๐1 = 4, ๐2 = 14, ๐3= 194 โก 8 (mod 31) , and ๐4โก 62 โก 0 (mod 31) , hence๐5= 31is a prime.
When checking (5.2.5), we compute the modulo๐๐remainders of the๐๐, which requires๐ โ 2 โ log2๐๐steps of squaring (plus subtracting and reducing).
Proof. The numbers๐+๐โ3(where๐, ๐are integers) form a (commutative) ring (with identity element and without zero divisors) for the usual operations; we denote this ring by๐ป. In our proof we shall rely on the elementary properties of divisibility, con- gruences, and order in๐ป(which hold exactly the same way as for the integers). Unique prime factorization is valid in๐ป(see Theorem 10.3.6 and Exercise 10.3.1), but we shall not need this result in our argument.
I. We can easily verify by induction that
๐๐= (2 + โ3)2๐โ1+ (2 โ โ3)2๐โ1 holds for every๐. Hence (5.2.5) is equivalent to the divisibility (5.2.6) ๐๐โฃ (2 + โ3)2๐โ2 + (2 โ โ3)2๐โ2. Factoring the right-hand side in (5.2.6), we obtain
(5.2.7) ๐๐โฃ (2 โ โ3)2๐โ2((2 + โ3)2๐โ1+ 1).
We note that the divisibility in (5.2.7) holds among the integers if and only if it is valid in๐ป(see Exercise 5.2.10), and(2 โ โ3)(2 + โ3) = 1implies that2 ยฑ โ3raised to
5.2. Fermat and Mersenne Primes 123
integer powers are units in๐ป. Therefore (5.2.7) and thus (5.2.5) are equivalent to the congruence
(5.2.8) (2 + โ3)2๐โ1 โก โ1 (mod ๐๐) .
We conclude that Theorem 5.2.4 can be reformulated as follows:๐๐is a prime if and only if (5.2.8) holds.
II. We shall need the following lemma: For any prime๐ > 3, we have (5.2.9) (๐ + ๐โ3)๐โก ๐ + (3
๐) ๐โ3 (mod ๐) . Proof of the lemma: Consider the binomial expansion (5.2.10) (๐ + ๐โ3)๐= ๐๐+ (๐
1)๐๐โ1๐โ3 + (๐
2)๐๐โ23๐2+ โฏ + ๐๐3(๐โ1)/2โ3.
By Fermatโs Little Theorem,
๐๐โก ๐ (mod ๐) and ๐๐โก ๐ (mod ๐) , further, each of
(๐ 1), (๐
2), . . . , ( ๐ ๐ โ 1) is divisible by๐, and
3(๐โ1)/2โก (3
๐) (mod ๐) . Substituting these into (5.2.10), we obtain (5.2.9) as stated.
III. Now we are in the position to show that (5.2.8) implies the primality of๐๐. Squaring (5.2.8), we have
(5.2.11) (2 + โ3)2๐ โก 1 (mod ๐๐) .
Let๐be a prime divisor of๐๐(clearly๐ > 3). Then (5.2.11) and (5.2.8) hold also for the modulus๐instead of๐๐. This yields (similar to the argument used in the proofs of Theorems 5.2.1 and 5.2.2) that๐๐(2 + โ3) = 2๐.
If(3๐) = 1, then by (5.2.9) we obtain
(2 + โ3)๐โ1= (2 โ โ3)(2 + โ3)๐โก (2 โ โ3)(2 + โ3) = 1 (mod ๐) , hence
๐๐(2 + โ3) = 2๐โค ๐ โ 1.
But this is impossible since๐ โค ๐๐= 2๐โ 1.
If(3๐) = โ1, then similarly
(2 + โ3)๐+1โก (2 โ โ3)(2 + โ3) = 1 (mod ๐) , thus
๐๐(2 + โ3) = 2๐โค ๐ + 1.
Comparing this with๐ โค ๐๐= 2๐โ 1, we have๐ = ๐๐, i.e.๐๐is a prime.
IV. Finally, we prove that if๐๐is a prime, then (5.2.8) must hold.
We shall use that๐๐โก โ1 (mod 8)implies
(5.2.12) ( 2
๐๐
) = 1,
further, using๐๐โก 1 (mod 3),๐๐โก โ1 (mod 4), and the law of reciprocity we get
(5.2.13) ( 3
๐๐) = โ (๐๐
3 ) = โ (1 3) = โ1.
Starting from the equality
2(2 + โ3) = (1 + โ3)2, we raise both sides to the power(๐๐+ 1)/2 = 2๐โ1:
(5.2.14) 2(๐๐+1)/2โ (2 + โ3)2๐โ1 = (1 + โ3)๐๐+1.
For the first factor on the left-hand side of (5.2.14), using (5.2.12), we obtain (5.2.15) 2(๐๐+1)/2= 2 โ 2(๐๐โ1)/2โก 2 ( 2
๐๐) = 2 (mod ๐๐) .
The right-hand side of (5.2.14) can be transformed as follows, applying (5.2.9) with ๐ + ๐โ3 = 1 + โ3and๐ = ๐๐, and using (5.2.13):
(5.2.16)
(1 + โ3)๐๐+1= (1 + โ3)(1 + โ3)๐๐
โก (1 + โ3)(1 + ( 3 ๐๐) โ3)
= (1 + โ3)(1 โ โ3) = โ2 (mod ๐๐) . Substituting (5.2.15) and (5.2.16) into (5.2.14), we infer
(5.2.17) 2(2 + โ3)2๐โ1 โก โ2 (mod ๐๐) .
Multiplying (5.2.17) by2๐โ1 and using2๐ โก 1 (mod ๐๐), we obtain the desired con-
gruence (5.2.8). โก
Exercises 5.2
1. (a) Verify๐น๐+1= ๐น0๐น1. . . ๐น๐+ 2.
(b) Demonstrate that the Fermat numbers are pairwise relatively prime (cf. Ex- ercise 1.3.14).
(c) Use part (b) to devise a new proof for the existence of infinitely many primes.
(d) Give a new proof for the statement of Exercise 5.1.9a.
2. Show that Theorem 5.2.2 remains valid for๐ โฅ 2if3 is replaced by5or10in formula (5.2.3).
3. Let๐ โฅ 2. Prove that๐พ๐= 5 โ 2๐+ 1is a prime if and only if 3(๐พ๐โ1)/2โก โ1 (mod ๐พ๐) .