Table Of ContentTable of Contents
Chapter 1 What is Number Theory? 1
Chapter 2 Pythagorean Triples 5
Chapter 3 Pythagorean Triples and the Unit Circle 11
Chapter 4 Sums of Higher Powers and Fermat’s Last Theorem 16
Chapter 5 Divisibility and the Greatest Common Divisor 19
Chapter 6 Linear Equations and the Greatest Common Divisor 25
Chapter 7 Factorization and the Fundamental Theorem of Arithmetic 30
Chapter 8 Congruences 35
Chapter 9 Congruences, Powers, and Fermat’s Little Theorem 40
Chapter 10 Congruences, Powers, and Euler’s Formula 43
Chapter 11 Euler’s Phi Function and the Chinese Remainder Theorem 46
Chapter 12 Prime Numbers 55
Chapter 13 Counting Primes 60
Chapter 14 Mersenne Primes 65
Chapter 15 Mersenne Primes and Perfect Numbers 68
Chapter 16 Powers Modulo mand Successive Squaring 75
Chapter 17 Computing kth Roots Modulo m 78
Chapter 18 Powers, Roots, and “Unbreakable” Codes 81
Chapter 19 Primality Testing and Carmichael Numbers 84
Chapter 20 Squares Modulo p 88
Chapter 21 Is –1 a Square Modulo p? Is 2? 91
Chapter 22 Quadratic Reciprocity 95
Chapter 23 Which Primes are Sums of Two Squares? 108
Chapter 24 Which Numbers are Sums of Two Squares? 113
Chapter 25 As Easy as One, Two, Three 116
Chapter 26 Euler’s Phi Function and Sums of Divisors 122
Chapter 27 Powers Modulo pand Primitive Roots 126
Chapter 28 Primitive Roots and Indices 135
Chapter 29 The Equation X4 + Y4 = Z4 138
Chapter 30 Square–Triangular Numbers Revisited 143
Chapter 31 Pell’s Equation 147
Chapter 32 Diophantine Approximation 152
Chapter 33 Diophantine Approximation and Pell’s Equation 156
Chapter 34 Number Theory and Imaginary Numbers 159
Chapter 35 The Gaussian Integers and Unique Factorization 163
Chapter 36 Irrational Numbers and Transcendental Numbers 168
Chapter 37 Binomial Coefficients and Pascal’s Triangle 176
Chapter 38 Fibonacci’s Rabbits and Linear Recurrence Sequences 180
Chapter 39 Oh, What a Beautiful Function 190
Chapter 40 Cubic Curves and Elliptic Curves 195
Chapter 41 Elliptic Curves with Few Rational Points 200
Chapter 42 Points on Elliptic Curves Modulo p 205
Chapter 43 Torsion Collections Modulo pand Bad Primes 211
Chapter 44 Defect Bounds and Modularity Patterns 215
© 2013, Pearson Education, Inc.
Chapter 45 The Topsy-Turvy World of Continued Fractions [online] 219
Chapter 46 Continued Fractions, Square Roots, and Pell’s Equation [online] 227
Chapter 47 Generating Functions [online] 232
Chapter 48 Sums of Powers [online] 240
© 2013, Pearson Education, Inc.
Chapter 1
What Is Number Theory?
Exercises
1.1. The first two numbers that are both squares and triangles are 1 and 36. Find the
next one and, if possible, the one after that. Can you figure out an efficient way to find
triangular–squarenumbers?Doyouthinkthatthereareinfinitelymany?
SolutiontoExercise1.1.
The first three triangular–square numbers are 36, 1225, and 41616. Triangular–square
numbersaregivenbypairs(m,n)satisfyingm(m+1)/2 = n2. Thefirstfewpairsare
(8,6), (49,35), (288,204), (1681,1189), and (9800,6930). The pattern for generating
these pairs is quite subtle. We will give a complete description of all triangular–square
numbersinChapter28, butfornowitwouldbeimpressivetomerelynoticeempirically
thatif(m,n)givesatriangular–squarenumber,thensodoes(3m+4n+1,2m+3n+1).
Startingwith(1,1)andapplyingthisrulerepeatedlywillactuallygivealltriangular–square
numbers.
1.2. Tryaddingupthefirstfewoddnumbersandseeifthenumbersyougetsatisfysome
sort of pattern. Once you find the pattern, express it as a formula. Give a geometric
verificationthatyourformulaiscorrect.
SolutiontoExercise1.2.
Thesumofthefirstnoddnumbersisalwaysasquare.Theformulais
1+3+5+7+··· +(2n−1)=n2.
Thefollowingpicturesillustratethefirstfewcases,andtheymakeitclearhowthegeneral
caseworks.
7 7 7 7
5 5 5
3 3 5 5 5 7
3 3 5
1 3 3 3 5 7
1 3 5
1 3 5 7
1+3=4 1+3+5=9 1+3+5+7=16
1
© 2013, Pearson Education, Inc.
[Chap.1] WhatIsNumberTheory? 2
1.3. The consecutive odd numbers 3, 5, and 7 are all primes. Are there infinitely many
such“primetriplets”? Thatis,arethereinfinitelymanyprimenumberspsuchthatp+2
andp+4arealsoprimes?
SolutiontoExercise1.3.
Theonlyprimetripletis3,5,7. Thereasonisthatforanythreeoddnumbers,atleastone
of them must be divisible by 3. So in order for them all to be prime, one of them must
equal3. Itisconjecturedthatthereareinfinitelymanyprimespsuchthatp+2andp+6
areprime,butthishasnotbeenproved.Similarly,itisconjecturedthatthereareinfinitely
manyprimespsuchthatp+4andp+6areprime,butagainnoonehasaproof.
1.4. ItisgenerallybelievedthatinfinitelymanyprimeshavetheformN2+1,although
nooneknowsforsure.
(a) DoyouthinkthatthereareinfinitelymanyprimesoftheformN2−1?
(b) DoyouthinkthatthereareinfinitelymanyprimesoftheformN2−2?
(c) HowaboutoftheformN2−3?HowaboutN2−4?
(d) WhichvaluesofadoyouthinkgiveinfinitelymanyprimesoftheformN2−a?
SolutiontoExercise1.4.
Firstweaccumulatesomedata,whichwelistinatable. Lookingatthetable,weseethat
N2−1andN2−4arealmostneverequaltoprimes,whileN2−2andN2−3seemto
beprimesreasonablyoften.
N N2−1 N2−2 N2−3 N2−4
2 3 2 1 0
3 8=23 7 6=2·3 5
4 15=3·5 14=2·7 13 12=22·3
5 24=23·3 23 22=2·11 21=3·7
6 35=5·7 34=2·17 33=3·11 32=25
7 48=24·3 47 46=2·23 45=32·5
8 63=32·7 62=2·31 61 60=22·3·5
9 80=24·5 79 78=2·3·13 77=7·11
10 99=32·11 98=2·72 97 96=25·3
11 120=23·3·5 119=7·17 118=2·59 117=32·13
12 143=11·13 142=2·71 141=3·47 140=22·5·7
13 168=23·3·7 167 166=2·83 165=3·5·11
14 195=3·5·13 194=2·97 193 192=26·3
15 224=25·7 223 222=2·3·37 221=13·17
LookingattheevenvaluesofN intheN2−1column,wemightnoticethat22−1
isamultipleof3,that42−1isamultipleof5,that62−1isamultipleof7,andsoon.
2
© 2013, Pearson Education, Inc.
[Chap.1] WhatIsNumberTheory? 3
Havingobservedthis,weseethatthesamepatternholdsfortheoddN’s. Thus32−1is
amultipleof4and52−1isamultipleof6andsoon. SowemightguessthatN2−1
isalwaysamultipleofN +1. Thisisindeedtrue,anditcanbeprovedtruebythewell
knownalgebraicformula
N2−1=(N −1)(N +1).
SoN2−1willneverbeprimeifN ≥2.
TheN2−4columnissimilarlyexplainedbytheformula
N2−4=(N −2)(N +2).
Moregenerally,ifaisaperfectsquare,saya=b2,thentherewillnotbeinfinitelymany
primesoftheformN2−a,since
N2−a=N2−b2 =(N −b)(N +b).
On the other hand, it is believed that there are infinitely many primes of the form
N2 −2andinfinitelymanyprimesoftheformN2 −3. Generally, ifaisnotaperfect
square,itisbelievedthatthereareinfinitelymanyprimesoftheformN2−a.Butnoone
hasyetprovedanyoftheseconjectures.
1.5. Thefollowingtwolinesindicateanotherwaytoderivetheformulaforthesumofthe
firstnintegersbyrearrangingthetermsinthesum.Fillinthedetails.
1+2+3+···+n=(1+n)+(2+(n−1))+(3+(n−2))+···
=(1+n)+(1+n)+(1+n)+··· .
Howmanycopiesofn+1areinthereinthesecondline? Youmayneedtoconsiderthe
casesofoddnandevennseparately.Ifthat’snotclear,firsttrywritingitoutexplicitlyfor
n=6andn=7.
SolutiontoExercise1.5.
Supposefirstthatniseven.Thenwegetn/2copiesof1+n,sothetotalis
n n2+n
(1+n)= .
2 2
Next suppose that n is odd. Then we get n−1 copies of 1+n and also the middle
2
term n+1 whichhasn’tyetbeencounted.Toillustratewithn=9,wegroupthetermsas
2
1+2+···+9=(1+9)+(2+8)+(3+7)+(4+6)+5,
sothereare4copiesof10,plustheextra5that’sleftover.Forgeneraln,weget
n−1 n+1 n2−1 n+1 n2+n
(1+n)+ = + = .
2 2 2 2 2
3
© 2013, Pearson Education, Inc.
[Chap.1] WhatIsNumberTheory? 4
Anothersimilarwaytodothisproblemthatdoesn’tinvolvesplittingintocasesisto
simplytaketwocopiesofeachterm.Thus
2(1+2+···+n)=(1+2+···+n)+(1+2+··· +n)
=(1+2+··· +n)+(n+···+2+1)
=(1+n)+(2+n −1)+(3+n−2)+···+(n+1)
=(1+n)+(1+n)+··· +(1+n)
(cid:2) (cid:3)(cid:4) (cid:5)
ncopiesofn+1
=n(1+n)=n2+n
Thusthetwicethesum1+2+···+nequaln2+n,andnowdivideby2togettheanswer.
1.6. For each of the following statements, fill in the blank with an easy-to-check crite-
rion:
(a) M isatriangularnumberifandonlyif isanoddsquare.
(b) N isanoddsquareifandonlyif isatriangularnumber.
(c) Provethatyourcriteriain(a)and(b)arecorrect.
SolutiontoExercise1.6.
(a) M isatriangularnumberifandonlyif1+8M isanoddsquare.
(b) N isanoddsquareifandonlyif(N−1)/8isatriangularnumber.(NotethatifN is
anoddsquare,thenN2−1isdivisibleby8,since(2k+1)2 =4k(k+1)+1,and4k(k+1)
isamultipleof8.)
(c) IfM istriangular,thenM =m(m+1)/2,so1+8M =1+4m+4m2 =(1+2m)2.
Conversely, if1+8M isanoddsquare, say1+8M = (1+2k)2, thensolvingforM
givesM =(k+k2)/2,soM istriangular.
NextsupposeN isanoddsquare,sayN = (2k+1)2. Thenasnotedabove,(N −
1)/8=k(k+1)/2,so(N−1)/8istriangular.Conversely,if(N−1)/8istrianglular,then
(N−1)/8=(m2+m)/2forsomem,sosolvingforNwefindthatN =1+4m+4m2 =
(1+2m)2,soN isasquare.
4
© 2013, Pearson Education, Inc.
Chapter 2
Pythagorean Triples
Exercises
2.1. (a) WeshowedthatinanyprimitivePythagoreantriple(a,b,c),eitheraorbiseven.
Usethesamesortofargumenttoshowthateitheraorbmustbeamultipleof3.
(b) By examining the above list of primitive Pythagorean triples, make a guess about
whena,b,orcisamultipleof5.Trytoshowthatyourguessiscorrect.
SolutiontoExercise2.1.
(a)Ifaisnotamultipleof3,itmustequaleither3x+1or3x+2. Similarly,ifbisnot
amultipleof3,itmustequal3y+1or3y+2. Therearefourpossibilitiesfora2+b2,
namely
a2+b2 =(3x+1)2+(3y+1)2 =9x2+6x+1+9y2+6y+1
=3(3x2+2x+3y2+2y)+2,
a2+b2 =(3x+1)2+(3y+2)2 =9x2+6x+1+9y2+12y+4
=3(3x2+2x+3y2+4y+1)+2,
a2+b2 =(3x+2)2+(3y+1)2 =9x2+12x+4+9y2+6y+1
=3(3x2+4x+3y2+2y+1)+2,
a2+b2 =(3x+2)2+(3y+2)2 =9x2+12x+4+9y2+12y+4
=3(3x2+4x+3y2+4y+2)+2.
Soifaandbarenotmultiplesof3,thenc2 = a2+b2 lookslike2morethanamultiple
of3.Butregardlessofwhethercis3zor3z+1or3z+2,thenumbersc2cannotbe2more
thanamultipleof3.Thisistruebecause
(3z)2 =3·3z,
(3z+1)2 =3(3z2+2z)+1,
(3z+2)2 =3(3z2+4z+1)+1.
5
© 2013, Pearson Education, Inc.
[Chap.2] PythagoreanTriples 6
(b) ThetablesuggeststhatineveryprimitivePythagoreantriple,exactlyoneofa,b,orc
isamultipleof5.Toverifythis,weusethePythagoreanTriplesTheoremtowriteaandb
asa = standb = 1(s2−t2). Ifeithersortisamultipleof5,thenaisamultipleof5
2
andwe’redone. Otherwiseslookslikes = 5S+iandtlookslike5T +j withiandj
beingintegersintheset{1,2,3,4}.Nextweobservethat
2b=s2−t2 =(5S+i)2−(5T +j)2 =25(S2−T2)+10(Si−Tj)+i2−j2.
Ifi2−j2 isamultipleof5,thenbisamultipleof5,andagainwe’redone. Lookingat
the16possibilitiesforthepair(i,j),weseethatthisaccountsfor8ofthem,leavingthe
possibilities
(i,j)=(1,2), (1,3), (2,1), (2,4), (3,1), (3,4), (4,2), or(4,3).
Nowforeachoftheseremainingpossibilities,weneedtocheckthat
2c=s2+t2 =(5S+i)2+(5T +j)2 =25(S2+T2)+10(Si+Tj)+i2+j2
is a multiple of 5, which means checking that i2 +j2 is a multiple of 5. This is easily
accomplished:
12+22 =5 12+32 =1021+12 =5 22+42 =20 (2.1)
31+12 =1032+42 =2542+22 =2042+32 =25. (2.2)
.
2.2. A nonzero integer d is said to divide an integer m if m = dk for some number k.
Showthatifddividesbothmandn,thendalsodividesm−nandm+n.
SolutiontoExercise2.2.
Bothmandnaredivisiblebyd,som = dk andn = dk(cid:2). Thusm±n = dk±dk(cid:2) =
d(k±k(cid:2)),som +nandm−naredivisiblebyd.
2.3. Foreachofthefollowingquestions,beginbycompilingsomedata;nextexaminethe
dataandformulateaconjecture;andfinallytrytoprovethatyourconjectureiscorrect.(But
don’tworryifyoucan’tsolveeverypartofthisproblem;somepartsarequitedifficult.)
(a) WhichoddnumbersacanappearinaprimitivePythagoreantriple(a,b,c)?
(b) WhichevennumbersbcanappearinaprimitivePythagoreantriple(a,b,c)?
(c) WhichnumbersccanappearinaprimitivePythagoreantriple(a,b,c)?
SolutiontoExercise2.3.
(a)AnyoddnumbercanappearastheainaprimitivePythagoreantriple. Tofindsucha
triple,wecanjusttaket = aands = 1inthePythagoreanTriplesTheorem. Thisgives
theprimitivePythagoreantriple(a,(a2−1)/2,(a2+1)/2).
(b) Looking at the table, it seems first that b must be a multiple of 4, and second that
everymultipleof4seemstobepossible. Weknowthatblookslikeb=(s2−t2)/2with
6
© 2013, Pearson Education, Inc.
[Chap.2] PythagoreanTriples 7
sandtodd.Thismeanswecanwrites=2m+1andt=2n+1.Multiplyingthingsout
gives
(2m+1)2−(2n+1)2
b= =2m2+2m−2n2−2n
2
=2m(m+1)− 2n(n+1).
Canyouseethatm(m+1)andn(n+1)mustbothbeeven,regardlessofthevalueofm
andn?Sobmustbedivisibleby4.
On the other hand, if b is divisible by 4, then we can write it as b = 2rB for some
odd number B and some r ≥ 2. Then we can try to find values of s and t such that
(s2−t2)/2=b.Wefactorthisas
(s−t)(s+t)=2b=2r+1B.
Nowboths−tands+tmustbeeven(sincesandtareodd),sowemighttry
s−t=2r and s+t=2B.
Solvingforsandtgivess=2r−1+Bandt=−2r−1+B. Noticethatsandtareodd,
sinceBisoddandr≥2.Then
a=st=B2−22r−2,
s2−t2
b= =2rB,
2
s2+t2
c= =B2+22r−2.
2
ThisgivesaprimitivePythagoreantriplewiththerightvalueofbprovidedthatB >2r−1.
Ontheotherhand,ifB <2r−1,thenwecanjusttakea=22r−2−B2instead.
(c) This part is quite difficult to prove, and it’s not even that easy to make the correct
conjecture. It turns out that an odd number c appears as the hypotenuse of a primitive
Pythagorean triple if and only if every prime dividing c leaves a remainder of 1 when
divided by 4. Thus c appears if it is divisible by the primes 5,13,17,29,37,..., but it
doesnot appear if it isdivisibleby anyof the primes3,7,11,19,23,.... Wewill prove
this in Chapter 25. Note that it is not enough that c itself leave a remainder of 1 when
dividedby4. Forexample, neither9nor21canappearasthehypotenuseofaprimitive
Pythagoreantriple.
2.4. InourlistofexamplesarethetwoprimitivePythagoreantriples
332+562 =652 and 162+632 =652.
FindatleastonemoreexampleoftwoprimitivePythagoreantripleswiththesamevalue
ofc.CanyoufindthreeprimitivePythagoreantripleswiththesamec?Canyoufindmore
thanthree?
7
© 2013, Pearson Education, Inc.
[Chap.2] PythagoreanTriples 8
SolutiontoExercise2.4.
Thenextexampleisc=5·17=85.Thus
852 =132+842 =362+772.
Ageneralruleisthatifc=p p ···p isaproductofrdistinctoddprimeswhichallleave
1 2 r
aremainderof1whendividedby4, thencappearsasthehypotenusein2r−1 primitive
Pythagorean triples. (This is counting (a,b,c) and (b,a,c) as the same triple.) So for
example,c=5·13·17=1105appearsin4triples,
11052 =5762+9432 =7442+8172 =2642+10732 =472+11042.
Butitwouldbedifficulttoprovethegeneralruleusingonlythematerialwehavedeveloped
sofar.
2.5. InChapter1wesawthatthenthtriangularnumberT isgivenbytheformula
n
n(n+1)
T =1+2+3+···+n= .
n 2
Thefirstfewtriangularnumbersare1,3,6,and10.InthelistofthefirstfewPythagorean
triples(a,b,c),wefind(3,4,5),(5,12,13),(7,24,25),and(9,40,41).Noticethatineach
case,thevalueofbisfourtimesatriangularnumber.
(a) FindaprimitivePythagoreantriple(a,b,c)withb=4T . Dothesameforb=4T
5 6
andforb=4T .
7
(b) DoyouthinkthatforeverytriangularnumberT , thereisaprimitivePythagorean
n
triple(a,b,c)withb=4T ?Ifyoubelievethatthisistrue,thenproveit.Otherwise,
n
findsometriangularnumberforwhichitisnottrue.
SolutiontoExercise2.5.
(a)T =15and(11,60,61).T =21and(13,84,85).T =28and(15,112,113).
5 6 7
(b) TheprimitivePythagoreantripleswithbevenaregivenbyb=(s2−t2)/2,s>t≥
1,sandtoddintegers,andgcd(s,t) = 1. Sincesisodd,wecanwriteitass = 2n+1,
andwecantaket = 1. (Theexamplessuggestthatwewantc = b+1,whichmeanswe
needtotaket=1.)Then
s2−t2 (2n+1)2−1 n2+n
b= = =2n2+2n=4 =4T .
2 2 2 n
SoforeverytriangularnumberT ,thereisaPythagoreantriple
n
(2n+1,4T ,4T +1).
n n
(ThankstoMikeMcConnellandhisclassforsuggestingthisproblem.)
2.6. IfyoulookatthetableofprimitivePythagoreantriplesinthischapter,youwillsee
manytriplesinwhichcis2greaterthana. Forexample,thetriples(3,4,5),(15,8,17),
(35,12,37),and(63,16,65)allhavethisproperty.
(a) FindtwomoreprimitivePythagoreantriples(a,b,c)havingc=a+2.
8
© 2013, Pearson Education, Inc.