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 bmodm and read a is congruent to b modm,
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 2mod7, but also 65 q "19mod7, 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 modm, because it has
melements 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 m
2. For instance"2 is a least residue of 89mod13, since
89 q "2mod13 and |"2| 2 132 . The set of least residues mod 13 is £"6,"5,...,"1,0,1,...,5,6¤. A set of least residues mod6 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. a q amodm for all a.
2. If a q bmodm, then b q amodm.
4. If two numbers are congruent to a third, they are also congruent to each other. (This follows from 2 and 3.)
5. If a q bmodm and c q dmodm, then
a c q b dmodm,
a" c q b " dmodm, and
ac q bdmodm. [If a b gm and c d hm, then ac bd bh cg ghm m.]
6. If a q bmodm, then ag q bgmodm for any integer g, i.e., a congruence can be multiplied by any number.
7. 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 bmodm by g resulting in a
g q bg mod m. For
example from 49 q 14mod5, it follows that 7 q 2mod5.
8. If S £a1, a2, . . . , am¤ is a complete residue system modm, and
gcda,m 1, then ax q bmodm 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 1modm. Then asx q sbmodm, and x q sbmodm. Furthermore sb is
congruent to just one element of S. ]
9. If S £a1, a2, . . . , am¤ is a complete residue system modm, and
gcda,m 1, then so is T £aa1, aa2, . . . , aam¤.
[aai q aajmod m ´ ai q ajmod m by 7. Thus the elements of T are distinct
and no two are congruent mod m. Each ai is congruent to some aajmod m
since ax q aimod m has a unique solution aj 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. ais a quadratic residue (QR)mod m if gcda,m 1 and
x2 q amodm 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 82 q 12mod13, while "1 is a QNR mod3, since x2 q "1mod3 has
no solution.
Notation. If gcda,p 1, p a prime, a p
1 if a is a QR modp and a p
"1 if a is a QNR mod p.
is the Legendre symbol.ap
1213 1,
"13 "1.
Throughout the following, p denotes an odd prime number.
Theorem 2. There are a total of P p"12 mutually incongruent QRs and just as many mutually incongruent QNRs mod p. The QRs are 12, 22, . . . , P2mod p.
Proof. No two of (the QRs) 12, 22, . . . , P2 are congruent mod p, because with
x, y £1,2,...,P¤, x2 q y2mod 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 P2
. Indeed, considerP h 2mod p. Let |k| t P be such that
one of the QRs 12, 22, . . . , P2mod 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 mod p. R
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 r1 and r2be QRs, and n1and n2 be QNRs mod p.
1. From a12 q r1, a22 q r2, we obtaina1a2 2 q r1r2mod p, and thus r1r2is a
QR.
2. The 2P numbers 12, 22, . . . , P2, n
1 12, n1 22, . . . , n1 P2are mutually
incongruent mod p. Since the first P of these numbers are QRs mod p, and since only P QRs exist, the P numbers n1 12, n1 22, . . . , n1 P2must be
QNRs, i.e., nirj is a QNR.
3. The 2P numbers n1 12, n1 22, . . . , n1 P2, n1n2 12, n1n2 22, . . . , n1n2 P2
are mutually incongruent mod p. The first P of them, by 2, are QNRs; thus the others must be QRs, among them n1n2. R
Theorem 4. Let gcda,p 1. Then a is a QR modp if aP q 1modp, and a is a QNR modp
if if aP q "1modp. In terms of the Legendre symbol a p
q ap"12 mod p.
Proof. For any x S £1,2,...,p " 1¤, there is a unique y S such that xy q amodp. Pick x1 arbitrarily in S, and let y1 S be that number such that x1y1 q amodp. Then
pick x2 in S different from x1 and y1, and let y2 be that number so that x2y2 q amodp.
Continue in this manner until all the numbers in S have been used.
If a is a QR, then for some v, xv yv, i.e. xv2 q amodp. The same is true for
x6 p " xv, and xv and x6are the only solutions to x2 q amodp in S.
Furthermore xvx6 xvp" xv2 q "amodp. Multiply all the P " 1 congruences
xy q amodp with this last one to get
p " 1 ! q "aPmod p.
Note that when a 1 (clearly a QR), we have
Wilson’s Theorem p " 1 ! q "1modp.
By Wilson’s Theorem, we conclude that if a is a QR, then aP q 1modp.
If a is a QNR, then there are exactly P congruences xy q amodp, and x and y are never equal. Multiply them all together to getp " 1 ! q aPmod p, and by
Wilson’s Theorem, aP q "1modp. R
Corollary. "1 "1p p"1
2 . Proof. q "1 "1p
p"1
2 mod p, and since both sides areo1, it follows that they are in fact equal (since p 4 2). R
Theorem 5. (Euler)"1 is a QR modp if and only if p q 1mod4.
Proof. If p q 1mod4, then p 1 4n, p"12 2n is even, and "1 "1p
Ifp q 3mod4, then p"12 is odd, and "1 "1p p"1
2 "1. R
Thus, x2 1 q 0modp has a solution if and only if p is on the form 4n 1.
Theorem 6. If p|a2 b2 , but p 4 a and p 4 b, then p c2 d2 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 a2 b2 pf. If f 1, we’re done, so assume f 1. Next, without loss of
generality, we may assume that f p2. [If this is not the case, simply replace a and
bby their least residues a0 and b0mod p. Then a02 b02 pf0, and since |a0|, |b0| p2,
pf0 p 2 4 p2 4 1 2p 2
, and f0 p2. For example 502 11 2501 61 41, but
50 q "11mod61, and "11 2 12 122 61 2 with 2 61
2 . ] If) and * are least
residues for a and b mod f respectively, then)2 *2 ff
1 where f1 t 12f, and then
a2 b2 )2 *2 pf ff
1 pf2f1,
or
a) b* 2 a* " b) 2 pf2f 1.
Since a) b* q a2 b2 q 0modf, and a* " b) q ab " ba q 0modf, we can divide this
last equality through by f2 to get a 1
2 b
1
2 pf
1, where f1 t 12f. Now f1 p 0, for
otherwise) * 0, and f|a and f|b, say a mf,b nf, and then
a2 b2 mf 2 nf 2 pf, whence p m2 n2 f, and f 1, contrary to f 1.
If f1 1, a12 b12 p provides a representation of p as a sum of squares. If
f1 1, repeat this procedure starting with a12 b12 pf1to get a22 b22 pf2with
0 f2 t 12f1, etc. This method of constructing new equations with ever decreasing
fs continues until 1 appears (which it must). This last equation gives a representation of p as a sum of two squares. R
For example: 112 11 61 2 11 12 2 1 112 11 11 12 61 2 2 1 11 1 1 1 11 1 " 1 1 61 22 1 122 102 61 22 1 62 52 61. Theorem 7.
1. A prime number q of the form 4n 3 cannot be written as a sum of two squares.
2. 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).
1. Suppose that a2 b2 q. Then b2 q "a2mod q. b2 is certainly a QR mod q
(since it’s the square of b). On the other hand"1 is a QNR by Theorem 5,
a2 is certainly a QR, and Theorem 3 implies that"a2 is a QNR. This
makes b2 both a QR and a QNR, a contradiction.
2. In this case, Theorem 5 guarantees the existence of x so that p|x2 1 .
Then Theorem 6 implies that p a2 b2for some positive integers a and
b. Assume that there is a second representation p A2 B2. Then
p2 a2 b2 A2 B2 Aa o Bb 2 Ab # Ba 2
. Since
p divides A2p" b2p A2a2 b2 " b2A2 B2
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 A2b2 B2a2or A2a2 B2b2.
The first of these equations implies that A2
a2
B2
b2
A2B2
a2b2 1, and
A a and B b while the second implies that A2
b2
B2
a2
A2B2
b2a2 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
B2
b2 ´ A
2 kB2 and a2 kb2 for some k (not necessarily an integer). Then
A2B2 a2b2 B2k1 b2k1 B2 b2 .