19. The Fermat-Euler Prime Number Theorem Every prime number of the form 4n 1 can be written as a sum of two squares in only one way (aside from the order of the summands). This famous theorem was discovered about 1660 by Pierre de Fermat (1601-1665), the greatest French mathematician of the seventeenth century. It was not published, however, until 1670, when it appeared, unfortunately without proof, in the notes of the works of Diophantus, edited by Fermat’s son. It is not certain whether or not Fermat had obtained a proof. The first proof of the theorem was presented almost 100 years later by Leonhard Euler in his treatise "Demonstratio theorematis Fermtiani, omnem numerum primum formae 4n 1 esse summam duorum quadratorum" (Novi Commentarii Academiae Petropolitanae ad annos 1754-1755, vol. V), after years of fruitless attempts at its proof. Today there are several proofs of the theorem. The following one is noted for its simplicity. It does however use a fair number of results from number theory, some of which will be need in No. 22 as well. In the following, all variables represent integers (whole numbers). Definition Two numbers a and b (according to Gauss), are congruent mod m, m being a positive integer, written a q b mod m and read a is congruent to b mod m, if their difference is divisible by m, i.e., m|a " b . Notes Every number is congruent to its remainder, or residue, when divided by m. For example 65 q 2 mod 7, but also 65 q "19 mod 7, thinking of 65 7 12 " 19. Conventional or common residues are nonnegative integers less than or equal to m. The set £0, 1, 2, . . . , m " 1 ¤ is a complete residue system mod m, because it has m elements no two of which are congruent mod m, (and every integer is congruent mod m to one of its members). A minimal (or least) residue mod m is a residue whose absolute value is less than or equal to m2 . For instance "2 is a least residue of 89 mod 13, since 89 q "2 mod 13 and |"2| 2 132 . The set of least residues mod 13 is £"6, "5, . . . , "1, 0, 1, . . . , 5, 6 ¤. A set of least residues mod 6 is £"2, "1, 0, 1, 2, 3 ¤ as is £"3, "2, "1, 0, 1, 2 ¤. A set of least residues mod m is a complete residue system. Theorem 1. 1. 2. 3. a q a mod m for all a. If a q b mod m, then b q a mod m. If a q b mod m and b q c mod m, then a q c mod m. 1 4. 5. 6. 7. 8. 9. If two numbers are congruent to a third, they are also congruent to each other. (This follows from 2 and 3.) If a q b mod m and c q d mod m, then a c q b d mod m, a " c q b " d mod m, and ac q bd mod m. [If a b gm and c d hm, then ac bd bh cg ghm m. ] If a q b mod m, then ag q bg mod m for any integer g, i.e., a congruence can be multiplied by any number. If g|a, g|b and gcdg, m 1, i.e., g and m are relatively prime, then we can divide the congruence a q b mod m by g resulting in ag q bg mod m. For example from 49 q 14 mod 5, it follows that 7 q 2 mod 5. If S £a 1 , a 2 , . . . , a m ¤ is a complete residue system mod m, and gcda, m 1, then ax q b mod m has a unique solution (or root) in S. [gcda, m 1 ´ there are integers s and t such that as mt 1 or as q 1 mod m. Then asx q sb mod m, and x q sb mod m. Furthermore sb is congruent to just one element of S. ] If S £a 1 , a 2 , . . . , a m ¤ is a complete residue system mod m, and gcda, m 1, then so is T £aa 1 , aa 2 , . . . , aa m ¤. [aa i q aa j mod m ´ a i q a j mod m by 7. Thus the elements of T are distinct and no two are congruent mod m. Each a i is congruent to some aa j mod m since ax q a i mod m has a unique solution a j by 8. Hence every integer n is congruent to some element in S and then also in T. ] We also need some results about quadratic residues. Definition. a is a quadratic residue (QR)mod m if gcda, m 1 and x 2 q a mod m for some integer x. If there is no such x, then a is a quadratic nonresidue (QNR). For example, 12 is a QR mod 13, since 8 2 q 12 mod 13, while "1 is a QNR mod 3, since x 2 q "1 mod 3 has no solution. Notation. If gcda, p 1, p a prime, ap 1 if a is a QR mod p and ap "1 if a is a QNR mod p. ap is the Legendre symbol. 12 1, 13 "1 "1. 3 Throughout the following, p denotes an odd prime number. p"1 Theorem 2. There are a total of P 2 mutually incongruent QRs and just as many mutually incongruent QNRs mod p. The QRs are 1 2 , 2 2 , . . . , P 2 mod p. Proof. No two of (the QRs) 1 2 , 2 2 , . . . , P 2 are congruent mod p, because with x, y £1, 2, . . . , P ¤, x 2 q y 2 mod p ´ p|x y x " y , but this can’t happen since 0 |x y|,|x " y| p. This give us P mutually incongruent QRs. No new QRs are obtained going beyond P 2 . Indeed, consider P h 2 mod p. Let |k| t P be such that P h q k mod p (i.e., k is the least residue of P h mod p). Then P h 2 q k 2 mod p, 2 one of the QRs 1 2 , 2 2 , . . . , P 2 mod p. Since there are (aside from 0 mod p) 2P mutually incongruent numbers mod p, there must be a total of P mutually incongruent QNRs R mod p. Theorem 3. The product of two QRs and the product of two QNRs is a QR; the product of a QR and a QNR is a QNR. Proof. Let r 1 and r 2 be QRs, and n 1 and n 2 be QNRs mod p. 1. 2. 3. From a 21 q r 1 , a 22 q r 2 , we obtain a 1 a 2 2 q r 1 r 2 mod p, and thus r 1 r 2 is a QR. The 2P numbers 1 2 , 2 2 , . . . , P 2 , n 1 1 2 , n 1 2 2 , . . . , n 1 P 2 are mutually incongruent mod p. Since the first P of these numbers are QRs mod p, and since only P QRs exist, the P numbers n 1 1 2 , n 1 2 2 , . . . , n 1 P 2 must be QNRs, i.e., n i r j is a QNR. The 2P numbers n 1 1 2 , n 1 2 2 , . . . , n 1 P 2 , n 1 n 2 1 2 , n 1 n 2 2 2 , . . . , n 1 n 2 P 2 are mutually incongruent mod p. The first P of them, by 2, are QNRs; thus R the others must be QRs, among them n 1 n 2 . Theorem 4. Let gcda, p 1. Then a is a QR mod p if a P q 1 mod p, and a is a QNR mod p p"1 if if a P q "1 mod p. In terms of the Legendre symbol ap q a 2 mod p. Proof. For any x S £1, 2, . . . , p " 1 ¤, there is a unique y S such that xy q a mod p. Pick x 1 arbitrarily in S, and let y 1 S be that number such that x 1 y 1 q a mod p. Then pick x 2 in S different from x 1 and y 1 , and let y 2 be that number so that x 2 y 2 q a mod p. Continue in this manner until all the numbers in S have been used. If a is a QR, then for some v, x v y v , i.e. x 2v q a mod p. The same is true for x 6 p " x v , and x v and x 6 are the only solutions to x 2 q a mod p in S. Furthermore x v x 6 x v p " x 2v q "a mod p. Multiply all the P " 1 congruences xy q a mod p with this last one to get P p " 1 ! q "a mod p. Note that when a 1 (clearly a QR), we have Wilson’s Theorem p " 1 ! q "1 mod p. By Wilson’s Theorem, we conclude that if a is a QR, then a P q 1 mod p. If a is a QNR, then there are exactly P congruences xy q a mod p, and x and y are never equal. Multiply them all together to get p " 1 ! q a P mod p, and by Wilson’s Theorem, a P q "1 mod p. R Corollary. "1 p "1 p"1 2 . p"1 Proof. "p1 q "1 2 mod p, and since both sides are o1, it follows that they are in fact equal (since p 4 2). R Theorem 5. (Euler) "1 is a QR mod p if and only if p q 1 mod 4. Proof. If p q 1 mod 4, then p 1 4n, p"1 2 2n is even, and "p1 "1 2n 1. 3 Ifp q 3 mod 4, then p"1 2 is odd, and "p1 "1 p"1 2 "1. R Thus, x 2 1 q 0 mod p has a solution if and only if p is on the form 4n 1. Theorem 6. If p|a 2 b 2 , but p 4 a and p 4 b, then p c 2 d 2 for some integers c and d. (This with Theorem 5 shows that only those primes of the form 4n 1 can be written as sums of squares.) Proof. Let a 2 b 2 pf. If f 1, we’re done, so assume f 1. Next, without loss of p generality, we may assume that f 2 . [If this is not the case, simply replace a and p b by their least residues a 0 and b 0 mod p. Then a 20 b 20 pf 0 , and since |a 0 |, |b 0 | 2 , p2 p2 p pf 0 4 4 12 p 2 , and f 0 2 . For example 50 2 1 1 2501 61 41, but 2 50 q "11 mod 61, and "11 1 2 122 61 2 with 2 612 . ] If ) and * are least residues for a and b mod f respectively, then ) 2 * 2 ff 1 where f 1 t 12 f, and then a 2 b 2 ) 2 * 2 pf ff 1 pf 2 f 1 , or ) b* 2 a* " b) 2 pf 2 f 1 . Since a) b* q a 2 b 2 q 0 mod f, and a* " b) q ab " ba q 0 mod f, we can divide this last equality through by f 2 to get a 21 b 21 pf 1 , where f 1 t 12 f. Now f 1 p 0, for otherwise ) * 0, and f|a and f|b, say a mf, b nf, and then a 2 b 2 mf 2 nf 2 pf, whence p m 2 n 2 f, and f 1, contrary to f 1. If f 1 1, a 21 b 21 p provides a representation of p as a sum of squares. If f 1 1, repeat this procedure starting with a 21 b 21 pf 1 to get a 22 b 22 pf 2 with 0 f 2 t 12 f 1 , etc. This method of constructing new equations with ever decreasing a fs continues until 1 appears (which it must). This last equation gives a R representation of p as a sum of two squares. For example: 11 2 1 1 61 2 11 12 2 1 1 1 1 1 1 2 11 1 1 1 11 1 " 1 1 12 2 10 2 62 52 11 2 61 2 2 1 61 2 2 1 61 2 2 1 61. Theorem 7. 1. 2. A prime number q of the form 4n 3 cannot be written as a sum of two squares. Every prime number p of the form 4n 1 can be written as a sum of two squares in exactly one way (up to the order in which the summands are written). Proof. 4 1. 2. Suppose that a 2 b 2 q. Then b 2 q "a 2 mod q. b 2 is certainly a QR mod q (since it’s the square of b). On the other hand "1 is a QNR by Theorem 5, a 2 is certainly a QR, and Theorem 3 implies that "a 2 is a QNR. This makes b 2 both a QR and a QNR, a contradiction. In this case, Theorem 5 guarantees the existence of x so that p|x 2 1 . Then Theorem 6 implies that p a 2 b 2 for some positive integers a and b. Assume that there is a second representation p A 2 B 2 . Then p 2 a 2 b 2 A 2 B 2 Aa o Bb 2 Ab # Ba 2 . Since divides A 2 p " b 2 p A 2 a 2 b 2 " b 2 A 2 B 2 p A2a2 " B2b2 Aa Bb Aa " Bb , p|Aa Bb or p|Aa " Bb . Since Aa Bb 0 and Ab Ba 0, we conclude that either Aa Bb p and at the same time Ab " Ba 0 or Ab Ba p and at the same time Aa " Bb 0 and either A 2 b 2 B 2 a 2 or A 2 a 2 B 2 b 2 . 2 2 2 2 The first of these equations implies that Aa 2 Bb 2 Aa 2 Bb 2 1, and 2 2 2 2 A a and B b while the second implies that Ab 2 Ba 2 Ab 2 Ba 2 1, and A b and B a. Thus the representation of p as a sum of two squares is unique up to the order in which the squares are written. R Note. A2 a2 A 2 B 2 a 2 b 2 ´ B2 A2 b2 B 2 k1 b 2 k1 kB 2 and a 2 kb 2 for some k (not necessarily an integer). Then B2 b2 . 5