00 Number Theory Step by Step
00 Number Theory Step by Step
00 Number Theory Step by Step
Number Theory
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Number Theory
Step by Step
Kuldeep Singh
1
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
3
Great Clarendon Street, Oxford, OX2 6DP,
United Kingdom
Oxford University Press is a department of the University of Oxford.
It furthers the University’s objective of excellence in research, scholarship,
and education by publishing worldwide. Oxford is a registered trade mark of
Oxford University Press in the UK and in certain other countries
© Kuldeep Singh 2020
The moral rights of the author have been asserted
First Edition published in 2020
Impression: 1
All rights reserved. No part of this publication may be reproduced, stored in
a retrieval system, or transmitted, in any form or by any means, without the
prior permission in writing of Oxford University Press, or as expressly permitted
by law, by licence or under terms agreed with the appropriate reprographics
rights organization. Enquiries concerning reproduction outside the scope of the
above should be sent to the Rights Department, Oxford University Press, at the
address above
You must not circulate this work in any other form
and you must impose this same condition on any acquirer
Published in the United States of America by Oxford University Press
198 Madison Avenue, New York, NY 10016, United States of America
British Library Cataloguing in Publication Data
Data available
Library of Congress Control Number: 2020944857
ISBN 978–0–19–884673–4
Printed and bound by
CPI Group (UK) Ltd, Croydon, CR0 4YY
Links to third party websites are provided by Oxford in good faith and
for information only. Oxford disclaims any responsibility for the materials
contained in any third party website referenced in this work.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Number theory is one of the oldest branches of mathematics, and because of the burgeoning growth of
internet security we see applications of number theory prevalent in this field of security.
Historically, one of my primary concerns has been in finding a rigorous yet accessible textbook to
recommend to students. Based on the popularity of my previously published books, Engineering Mathe-
matics through Applications and Linear Algebra Step by Step, I have felt a need to write a book on number
theory that bridges the considerable divide between school and undergraduate mathematics.
I have been fortunate in that I had some students to assist in evaluating each chapter, and in response
to their reaction, I consequently modified, expanded, and added sections to ensure that its content en-
tirely encompassed the ability of students with a limited mathematical background, as well as the more
advanced readers. I believe this has allowed me to create a book that is simple in its explanation, yet
comprehensive in its approach to even the most challenging aspects of this topic.
Level
This book is intended for first- and second-year undergraduates. Many students find the transition be-
tween school and undergraduate mathematics difficult, and this book specifically addresses that gap and
allows seamless progression. It assumes limited prior mathematical knowledge, yet also covers difficult
material and answers tough questions through the use of clear explanation and a wealth of illustrations.
The emphasis of the book is on students learning for themselves by gradually absorbing clearly presented
text, supported by patterns, graphs, and associated questions.
Pedagogical Issues
The strength of the text is in the large number of examples and the step-by-step explanation of each topic
as it is introduced. It is compiled in such a way that allows self-study, with explicit solutions to all the sets
of problems freely available online. Also included are short historical biographies of the leading players
in the field of number theory. These are generally placed at the beginning of a section to engage the
interest of the student from the outset.
At the University of Hertfordshire there are between 70 and 80 mathematics undergraduates. In the
past, we have based our number theory course on various existing textbooks, but in general students
have found them hard to digest or lacking in rigorous explanation. This is a book that allows the student
to gradually develop an understanding of this topic, without the need for constant additional support
from a tutor.
Proposed Book
A large number of books on number theory currently exist, but they are either difficult to comprehend
and have a very formal structure, or are too applied, so are suitable for engineers but not for mathemati-
cians or physicists. Published textbooks on this subject tend to be rather static in their presentation.
By contrast, this book strives to be significantly more dynamic and encourages the engagement of the
reader with frequent question and answer sections. The question–answer element is sprinkled liberally
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
vi P R EFAC E TO N U M B E R T H E O RY ST EP BY ST EP
throughout the text, consistently testing the student’s understanding of the methods introduced, rather
than requiring them to remember by rote.
I anticipate a broad appeal. The simple yet concise nature of its content is specifically designed to
aid the students, but its rigorous approach and comprehensive manner makes it entirely appropriate
reference material for mathematicians at every level.
Background
I have held the position of Senior Lecturer in Mathematics at the University of Hertfordshire for over 25
years, where I teach number theory to second-year undergraduates.
My interest in mathematics began at school. I am originally of Sikh descent, and as a young child
often found English difficult to comprehend, but I discovered an affinity with mathematics, a universal
language that I could begin to learn from the same starting point as my peers.
My passion has always been to teach, and I have taught number theory at the University of Hertford-
shire since 2008.
I am also the author of Engineering Mathematics through Applications, a book that I am proud to say
is used widely as the basis for undergraduate studies in many different countries. Additionally, I have
authored Linear Algebra Step by Step, which is also widely used.
I also host and regularly update a website dedicated to mathematics.
My family and career leave little room for outside interest, but I am a keen football fan and occasional
cyclist.
Acknowledgements
I would particularly like to thank Della Avery—Mathematics Teacher, Ágnes Bonivárt—PhD stu-
dent,and Dr Laurence Taylor—Analysis and Data Visualisation Specialist,for their significant help in
improving this text.
Also thanks to Bharath Krishnamoorthy for doing an excellent job of typesetting this book.
Dedication
Shaheed Bibi Upkar Kaur
Kuldeep Singh
School of Physics, Astronomy and Mathematics
University of Hertfordshire
College Lane
Hatfield, Herts AL10 9AB
[email protected]
Homepage http://maths-for-all.co.uk/
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Contents
1 A Survey of Divisibility 1
viii CON TE N TS
Introductory Chapter
Companion Website
Index 384
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Number theory is one of the oldest branches of mathematics. Four thousand years ago the Babylonians
were writing down Pythagorean triples, such as
562 + 902 = 1062, 1192 + 1202 = 1692 and 12 7092 + 13 5002 = 18 5412 .1
However, since the advent of digital computer, number theory has seen a resurgence in interest, due to its
applications in computer science and cryptography. Number theory had no serious application for nearly
four thousand years. It was not used in construction, aerospace, manufacturing, finance, economics etc.
Number theory does not highlight any discrepancies in the distribution of wealth or promote the
destruction of humanity. Despite this we use numbers in our daily life—entering our date of birth,
phoning a friend, entering our pin number at a cash point machine. Did you know that in China you
cannot use the pin number 8964, 4689, 040689, or any version of these? This is because Tiananmen
Square massacre occurred on the 4th June 1989.
Our intuition may suggest that there is nothing interesting about numbers, but we would be totally
deluded because numbers have some appealing properties which we discuss in this book. We will come
across curious and surprising results about numbers, in particular positive integers.
What attributes will you learn from this number theory book?
Intellectual rigour, problem solving, reasoning, ability to deal with abstract concepts and interpreting
your solution to a given problem. It will also help you develop logical deduction skills and creativity
when writing proofs of results. It is not a collection of isolated techniques or algorithms that can be used
to solve a problem.
Moreover, number theory has a very rich history and this history is sprinkled throughout the book.
Wouldn’t you like to know how Gauss, Fermat or Euler solved a particular problem?
Number theory is essentially the study of positive integers and in this book, we only use elementary
methods to examine this. We do not apply mathematical analysis or advanced algebra to study the topics
discussed. Elementary number theory is where elementary does not imply easy or basic but just simply
means only elementary methods can be used. It is like asking someone to do the hurdles with a chain and
ball around their neck because you cannot use analytic or advanced algebraic methods to find solutions.
Elementary in this context is misleading because it can be a real challenge.
A “feature” of number theory is that it’s easy to formulate questions that many people can understand
but for which we still don’t have an answer. For instance, we expect there are infinitely many primes of
the form n2 + 1 (you can even start making a list—it’s prime for n = 1, 2, 4, 6, 10, 14, 16, 20, 24, 26, 36,
40, 54, . . . ) but this remains an unsolved problem.
1
https://en.wikipedia.org/wiki/Plimpton_322
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
x IN TR ODU CT ION TO N U M B ER T H E O RY ST EP BY ST E P
Another easily understood statement is the Legendre conjecture which remains unproven and says:
‘There is always a prime between n2 and (n + 1)2 .’
This result look so innocent that you would think that you can prove it by induction, but it has re-
mained unproven for the last 200 years.
In the first chapter we look at divisibility of positive integers and we concentrate on the greatest common
divisor.
In Chapter 2 we prove the Fundamental Theorem of Arithmetic which claims that every positive
integer greater than 1 can be factorized into product of primes in a unique way. This Fundamental
Theorem of Arithmetic does not tell us how to factorize a given integer but just that a factorization
exists. In more modern applications of Number Theory such as cryptography, we are interested in the
following questions:
● How do we factorize a given positive integer?
● How to determine whether a given positive integer is prime?
Factorization is used in public-key encryption as it provides security because it is easy to multiply two
large primes but very difficult to factorize them. For example, multiplying the two primes
gives 23 456 761 × 9 876 543 139 = 231 671 711 917 712 779. However, factorizing the right-hand side
231 671 711 917 712 779 is a difficult task unless you know the above primes give this answer. This is,
in general a very hard problem, because no algorithms exist (yet) to find prime factorization efficiently.
How would you find a prime factor of 2251 − 1, which in decimal format is, 36185027886661311
06986593281521497120414687020801267626 233049500247285301247?
We will answer this question in Chapter 4. Why isn’t this factorization covered in Chapter 3?
This factorization is shown by introducing a new kind of arithmetic called modular or clock arithmetic
in Chapter 3. This clock arithmetic is carried out in a loop rather than a number line and focuses on the
remainder when two integers are divided. The remaining Chapters 4-8 rely on this modular arithmetic.
Additionally, in Chapter 3 we apply something called the Chinese Remainder Theorem which counts
things without actually counting them by using this new arithmetic.
Modular arithmetic can answer questions like-what are the last two digits of 11205 ? We examine these
types of questions in Chapter 5.
We use modular arithmetic to solve the following non –linear Diophantine equation
Diophantine equation means that the solutions x and y are restricted to being integers. In general
Diophantine equations are hard to solve by analytical means but we solve these and others of similar
nature in Chapters 6 and 7.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I NT RO D U C T I O N TO N U M B E R T H E O RY ST E P BY ST E P xi
x2 − 4183y = 713,
Additionally, in the last chapter we show that every positive integer n can be written as a sum of four
squares:
n = a2 + b2 + c2 + d2 .
Firstly, this is what is covered in most elementary number theory modules throughout the developed
world. I have just done a web search of such a course and nearly all of them contain the topics discussed
above.
Positive integers are fundaniental in everyday life and as every positive integer greater than 1 can
be factorizeded into primes so primes and divisibility lead to more general and powerful results. For
example, you may be interested in the last few digits of a large number which in compact notation is
written as an . Again, to answer such questions we need to use modular arithmetic and the theory of this
arithmetic is based on primes.
Some of the topics may seem like detour such as Diophantine equations but they help in solving
equations of modular arithmetic.
For all the topics discussed in the book you do not need any analysis or advanced algebra and the only
prerequisite is you know how to construct a proof, which is explained in the Introductory Chapter. You
can use these discussed topics as a basis to investigate analytic or algebraic number theory.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
..............................................................................................................................
1 A Survey of Divisibility
..............................................................................................................................
How would you find the greatest common divisor of 5291 and 3108?
How would you solve the equation 5291x + 3108y = c where x, y, and c are integers?
The aim of this chapter is to answer these types of questions. To answer these questions
we need to introduce the idea of divisibility and Euclidean algorithm, which is covered in
Sections 1.2 and 1.3 respectively of this chapter.
First in this section, we discuss divisors of integers so that we can define what is meant
by the greatest common divisor which is one of the basic building blocks of number theory.
The greatest common divisor plays an important part in factorizing numbers, which we
discuss in later chapters of the book.
The idea of divisibility is one which we are all familiar with, having encountered it early on
in our mathematical studies. The formal definition is:
Definition (1.1). We say integer a ≠ 0 divides integer b if and only if there exists an integer
m such that a × m = b.
We denote a divides b by a b.
Throughout the book, lower case italic letters will represent integers. For example, 5 100
because there is an integer m = 20 such that 5 × 20 =100. If a does not divide b then
we denote this by a b. For example, 5 101 because there is no integer m such that
5 × m = 101.
For the above example, 5 100, we say 5 is a divisor (or factor) of 100 or 100 is a multiple
of 5 because 5 × 20 = 100.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
2 1 A SURV EY OF D I V I S I B I L I T Y
Divisors and factors are synonymous and you will find that we interchange between the
two when discussing divisibility of integers.
Clearly 1, 3, 7, and 21 are divisors of 21, but so are −1, −3, −7, and −21. We have
We see that 3 −21 because 3 × (−7) = −21. Hence 3 is a divisor of −21. The divisors of
−21 are the same as the divisors of 21.
Note that in the list of divisors (factors) are both positive and negative integers.
Example 1.1
Solution
(a) The divisors of 100 are (remember ±a means +a or −a):
±1, ±2, ±4, ±5, ±10, ±20, ±25, ±50, and ±100.
±1, ±2, ±3, ±5, ±6, ±10, ±15, and ±30 are the divisors of 30.
Now that we have established what is meant by a divisor, we can list some of their prop-
erties. In particular, we generalize the results of Example 1.1 (b) and (d).
The generalized results about divisors are stated in the next theorem. A theorem or propo-
sition is a mathematical statement that is proved by using mathematical reasoning—see
Introductory Chapter.
(For a reminder of the meaning of the two-way implication symbol ⇔, see the Introduc-
tory Chapter).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T H E G R E AT E ST C O M M O N D I V I S O R ( 1 – 1 0 ) 3
Proof.
(a) We have an ⇔ in the statement, so we need to prove this both ways, ⇒ and ⇐.
For ⇒ we assume a 1 then deduce a = ±1.
For ⇐ we assume a = ±1 and deduce a 1.
(⇐). If a = ±1 (a = 1 or a = −1) then a 1 because 1 1 and −1 1.
1
(⇒). If a 1 then there is an integer m such that am = 1, which implies a = .
m
Since a is an integer so m = ±1 which gives a = ±1.
ax = b and by = c.
a × integer = c implies a c.
Recall ‘⇒’ denotes ‘implies’. We will interchange between these throughout the
book.
(c) We have a b and c d, therefore there are integers m and n such that
am = b and cn = d.
ax = b and by = a.
x = 1, y = 1 or x = −1, y = −1.
4 1 A SURV EY OF D I V I S I B I L I T Y
a × m = b.
Taking the modulus (check the Introductory Chapter to see what is meant by the
modulus function, | |, and for some of its properties) of both sides gives
| b | = | a | × | m | ≥ | a | × (1) = |a| .
We now give some numerical examples which make use of the results just presented.
Example 1.2
Solution
While we could easily list the divisors of 42, we will make use of Theorem (1.2) (b). We know that 6 is
a divisor of 42, so we use Theorem (1.2) (b) which states:
a b and b c ⇒ a c.
1, 2, 3, and 6.
Since 42 = 6 × 7, so by using Theorem (1.2) (b) again we can state that any divisors of 7 are also divisors
of 42. The divisors of 7 are
1 and 7.
The tau (pronounced ‘tour’) function of a positive integer, n, denoted by 𝜏 (n), gives the
number of positive divisors of n. For the above example we have 𝜏 (42) = 8. This 𝜏 (n) is an
important function in number theory.
From now on, we will concentrate on the positive divisors because we can find the neg-
ative ones by just placing a negative sign in front of the positive divisors.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T H E G R E AT E ST C O M M O N D I V I S O R ( 1 – 1 0 ) 5
Example 1.3
Given that 99 5544 and 168 1176, show, without using a calculator,
72 (5544 × 1176).
Solution
Since 72 = 9 × 8, so we need to show
(9 × 8) (5544 × 1176).
This linear combination is an important concept which is used throughout the book.
If a b and a c then a (bx + cy). We shall see the proof of this shortly, but beforehand
let us see a numerical demonstration.
Example 1.4
Given that 99 5544 and 99 594, show 99 (5544x + 594y) for any integers x and y.
Solution
We are given 99 5544, which implies there is an integer m such that
99m = 5544.
Similarly, from 99 594 there is an integer n such that 99n = 594. Considering the linear combination
5544x + 594y and substituting 99m = 5544 and 99n = 594 into this gives
=
⏟ 99 (mx + ny) = 99 (integer) [Sum of two integers is an integer] .
Factorizing
6 1 A SURV EY OF D I V I S I B I L I T Y
Let us now prove this result for any given choice of integers.
Linear Combination Theorem (1.3). If a b and a c then a (bx + cy) for any integers x
and y.
It says that if a divides both b and c then it divides any linear combination of b and c:
bx + cy.
Proof.
Suppose a b and a c. By Definition (1.1), there are integers m and n such that am = b and
an = c.
We are required to prove a (bx + cy). Substituting these b = am and c = an into the
linear combination bx + cy gives
We have a (integer) = bx + cy, therefore a (bx + cy). This completes our proof.
Example 1.5
Proof.
(i) Using Theorem (1.3) with x = y = 1 gives a (b + c).
(ii) Using Theorem (1.3) with x = 1 and y = −1 gives a (b − c).
Theorem (1.3) is only valid when a divides both integers; a b and a c. We can extend
Theorem (1.3) to apply to any number of integers:
If a b1 , a b2 , a b3 , ⋯ and a bn , then a divides any linear combination of these:
a (b1 x1 + b2 x2 + b3 x3 + ⋯ + bn xn ) .
T H E G R E AT E ST C O M M O N D I V I S O R ( 1 – 1 0 ) 7
What does the greatest common divisor (or highest common factor) mean?
Let us consider two integers, 15 and 35. The divisors of these numbers are:
1, 3, 5, and 15 are the positive divisors of 15.
1, 5, 7, and 35 are the positive divisors of 35.
1 and 5.
The greatest of these is 5, so we say that 5 is the greatest common divisor, or gcd, of 15
and 35.
The greatest common divisor of integers a and b is denoted by gcd (a, b). So, in the
case just discussed, we would write gcd (15, 35) = 5. The greatest common divisor is also
called the highest common factor in some texts, but we will stick to using greatest common
divisor.
Example 1.6
Suppose you want to tile a floor with dimensions 72 inches by 90 inches. What is the largest size of
square tile you can use to cover the entire floor without cutting any of the identical tiles?
Solution
How is this problem connected to the greatest common divisor?
Since we are to use square tiles, we need to find a common divisor of 72 and 90.
Also, we are looking for the largest size tiles, so we need to find the greatest common divisor, gcd,
of 72 and 90, or in notation form gcd (72, 90).
The positive divisors of 72 are {1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72}. Recall from the Introductory Chap-
ter that a set is denoted by braces { } and is used to illustrate a grouping.
Which of these numbers are also divisors of 90?
{1, 2, 3, 6, 9, 18}.
This {1, 2, 3, 6, 9, 18} is the set of common divisors of 72 and 90. Thus
You need to buy 18-inch square tiles in order to cover the whole floor without cutting any of them.
Definition (1.4). The positive integer g is the gcd of integers a and b which are not both
zero ⇔
(i) g a and g b [g is a common divisor]
(ii) If for any c we have c a and c b then c ≤ g [g is the largest of the common divisors].
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
8 1 A SURV EY OF D I V I S I B I L I T Y
Note that if gcd (a, b) = g where a and b are not both zero then g ≥ 1. It is important to
remember that g needs to satisfy both conditions (i) and (ii) in order to qualify as the gcd.
When finding the gcd we only need to consider the positive divisors, as gcd is a positive
integer. The following examples will present some cases of finding the gcd.
Example 1.7
Solution
(a) Since the gcd is positive, we only need to examine positive divisors of each number.
The positive divisors of −12 are {1, 2, 3, 4, 6, 12}.
The positive divisors of 30 are:
{1, 2, 3, 5, 6, 10, 15, 30}.
The common divisors of −12 and 30 are 1, 2, 3, and 6. Therefore,
Two integers that only have a common divisor (factor) of 1 are relatively prime to each
other; we cover this in Subsection 1.3.2 of this chapter. There, we will also show a more
efficient way of evaluating the gcd: the Euclidean Algorithm.
Example 1.8
T H E G R E AT E ST C O M M O N D I V I S O R ( 1 – 1 0 ) 9
We can use this result to simplify fractions. For example, we can simplify 36/60 by di-
36 3
viding the numerator and denominator by g = gcd (36, 60) = 12. We have = .
60 5
We can also use this division by the gcd to simplify ratios as you will see in Exercises 1.1,
question 3.
a b
Proposition (1.5). If gcd (a, b) = g then gcd ( , ) = 1.
g g
By contradiction.
Proof.
a b
Let gcd ( , ) = d and suppose d > 1. By Definition (1.4) (of the gcd) we have
g g
|a a |
d | ⇒ dm = ⇒ (dg) m = a ⇒ dg | a.
|g g |
Similarly,
|b b |
d | ⇒ dn = ⇒ (dg) n = b ⇒ dg | b.
|g g |
Hence dg is also a common divisor of a and b. Since gcd (a, b) = g, so by Definition (1.4) (ii):
if c a and c b then c ≤ g [g is the largest common divisor],
we must have dg ≤ g. Dividing both sides by g gives d ≤ 1. This cannot be the case because
our supposition says d > 1. We have a contradiction. Our supposition d > 1 must be wrong.
a b
Therefore d = 1, which means we have gcd ( , ) = 1. (The integers a/g, b/g are relatively
g g
prime.)
We can extend the definition of the greatest common divisor to more than two integers.
Definition (1.6). The positive integer g is the gcd of the set of integers S = {a1 , a2 , a3 , ⋯ , an }
which are all non-zero ⇔ g is the largest integer that divides all the integers in the set S.
This is normally denoted by g = (a1 , a2 , a3 , ⋯ , an ).
gcd (a, b, c) = gcd (a, gcd (b, c)) where a, b, c are non-zero integers.
10 1 A SURV EY OF D I V I S I B I L I T Y
Summary
The integer a is a divisor of b if and only if a × m = b where m is an integer.
If a b and a c then a is a divisor of any linear combination of b and c.
The gcd of a and b, gcd (a, b), is the largest integer which divides both a and b.
EXERCISES 1.1
(Brief solutions at end of book. Full By using this graph or otherwise, find
solutions available at <http://www.oup.co. two integer solutions to this equation:
uk/companion/NumberTheory>.)
24x + 120y = gcd (24, 120) .
1. You have a rectangular sheet of metal
of dimensions 60 inches by 84 inches. 8. Determine a particular integer
You want to cut this metal into smaller solution to 56x + 60y = gcd (56, 60).
identical squares. What is the largest 9. *Determine gcd (66, 165, 253).
size square you would need to ensure
there is no metal left over? 10. Determine gcd (a, a2 ) where a is a
non-zero integer.
2. Find gcd (57, 209). Hence or
57 11. Determine gcd (a + b, a2 − b2 ) where
otherwise simplify the fraction .
209 integers a + b and a2 − b2 are not both
3. Determine gcd (65, 1001). Hence zero.
write the ratio 65 ∶ 1001 in its simplest 12. Prove or disprove the following
form. statement:
4. In music, the fundamental frequency a b and c d implies (a + c) (b + d).
f0 is the gcd of the frequencies fn of the
harmonics. Find the fundamental 13. (a) Find the possible values of the
frequency f0 of the harmonics: integer a such that a 0.
(b) Find the possible values of the
f1 = 200Hz, f2 = 300Hz, f3 = 400Hz, integer a such that a 2.
and f4 = 500Hz.
14. Prove that a b ⇔ ac bc, provided
5. Compute 𝜏 (n) (tau function) for the c ≠ 0.
following n values: 15. Let a (b + c) and a b. Show that a c.
(a) 10 (b) 100 (c) 120 (d) 101 16. Prove that if a b and a c then
6. Determine the gcd of the following
a (b2 − c2 ) .
integers:
(a) −12, 34 (b) −36, −60 17. Show that a (b × c) /
⇒ a b or
(c) 60, −72 (d) 1001, 182 a c.
D I V I S I O N A LG O R I T H M ( 1 1 – 1 7 ) 11
18. Prove that (relatively prime means 21. *Prove that if d (n1 × n2 ) where d > 1
their gcd is 1): and gcd (n1 , n2 ) = 1, then only one of
the following holds:
(a) two consecutive integers are
relatively prime. either d n1 or d n2 .
(b) two consecutive odd integers are
22. Prove that gcd (−a, −b) = gcd (a, b)
relatively prime.
where a and b are not both
19. Let m and n be positive integers. Prove zero.
that if m n where m < n (m is a
n 23. Prove that if a b1 , a b2 , ⋯, and a bn
proper divisor) then m ≤ .
2 then a (b1 x1 + b2 x2 + ⋯ + bn xn ) for
20. *Show that if n is an odd integer then any integers x1 , x2 , ⋯ , xn .
gcd (n + 1, n2 + 1) = 2.
.........................................................................................................
In the last section we found the greatest common divisor, gcd, of two integers by listing
the divisors of these integers and then selecting the largest common divisor. This is a very
inefficient way of evaluating the gcd because listing the divisors of large integers will be
very time-consuming. We need a much more efficient way of determining the gcd, which
we develop in the next section: the Euclidean Algorithm. However, the use of the Euclidean
Algorithm is based on the Division Algorithm which is discussed in this section.
Our aim in this section is to show there is a unique way of expressing any given integer
in terms of a quotient and remainder. (You will see what these terms mean below.)
To introduce the concept of the quotient and remainder, we go back to long division. Let
us look at the simple case of 25 divided by 4:
6 Rem 1
4 25
−24
1
25 = 6 (4) + 1.
12 1 A SURV EY OF D I V I S I B I L I T Y
25 = 7 (4) − 3
25 = −5 (4) + 45
25 = 1 (4) + 21
⋮
In other words, there are infinitely many ways that we can write 25 as a multiple of 4 plus a
remainder. The question we wish to address is:
Is there a unique way of writing our integer in terms of a multiple and a remainder?
The answer is yes, and we achieve this by placing a restriction on the remainder; we require
that the remainder be greater than or equal to zero but less than what we are dividing by,
which in this case is 4. With this restriction, we have a unique way of dividing 25 by 4 which
is our first answer,
25 = 6 (4) + 1.
Before we look at proving this for the general case, we will consider some other examples.
Example 1.9
Express the following numbers in terms of quotient and remainder, where the remainder is the smallest
positive integer or zero (non-negative).
(a) 27 divided by 5 (b) 365 divided by 7 (c) −159 divided by 3
Solution
(a) We have 27 = 5 (5) + 2.
(b) Similarly, 365 = 52 (7) + 1.
(c) Finally, −159 = −53 (3) + 0.
In each of the above we have placed the quotient in front of the brackets.
We now generalize this result. Let a and b be any given integers with b ≥ 1. Then there
exists a quotient q and a remainder r, such that
a = bq + r.
The quotient q and remainder r for those cases given in Example 1.9 are:
If we restrict the remainder r such that 0 ≤ r < b, then q and r are unique in the expression
a = bq + r, which we prove in the next Subsection 1.2.2.
We can look at this geometrically, as seen in Figure 1.1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
D I V I S I O N A LG O R I T H M ( 1 1 – 1 7 ) 13
a=bq+r
0 b 2b qb
r
Figure 1.1 Geometric interpretation of the quotient and remainder expression of the integer a.
We choose our remainder r to be the smallest non-negative integer. The following exam-
ple is a demonstration of why we are interested in the smallest non-negative remainder.
Example 1.10
We have 51 litres of drink and we can get four portions out of each litre. There are 37 people at a party.
How many portions should we serve each person to be fair to everyone?
Solution
The total number of portions we have is 4 × 51 = 204. Writing this in the form a = bq + r where
0 ≤ r < b, with a = 204 and b = 37 gives
This means that to have a fair distribution of drinks we should serve each person five portions.
We are now able to write down the general form of the Division Algorithm and prove it. The
proof of the Division Algorithm is challenging because it uses inequalities, Well-Ordering
Principle (WOP), and Without Loss of Generality (WLOG). The WOP and WLOG have
been explained in the Introductory Chapter, but in a nutshell:
Well-Ordering Principle:
Every non-empty subset of positive integers has a least element.
Without Loss of Generality means that instead of considering every case we consider
a particular case and the remaining arguments are similarly applied to the other cases.
In the proof we also use notation from set theory (see Introductory Chapter). We can
define a set using a rule; for example,
{x ∶ x is an even number }
such that
which would be read as ‘x such that x is an even number’. This set would be equivalent to
{2, 4, 6, 8, ⋯} where three dots (ellipsis), ⋯, show that the pattern continues and the above
colon, :, represents ‘such that’.
Division Algorithm (1.7). Given any integers a and b where b ≥ 1, then there exist unique
integers q called the quotient and r called the remainder such that
a = bq + r where 0 ≤ r < b.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
14 1 A SURV EY OF D I V I S I B I L I T Y
How?
The clue is in the statement; we need to show two things: 1) the existence of q and r and
2) the uniqueness of these integers.
Proof.
1) Existence
Let T be the set T = {a, a − b, a − 2b, a − 3b, ⋯}. Remember, b is our divisor so we can take
away multiples of b from a. Let S be the set which are the non-negative integers in T. We
can write the set S in compact notation as
S = {a − mb ∶ m is an integer and a − mb ≥ 0} .
Why?
a − mb = a + |a| b ≥ 0 [Because b ≥ 1] .
This shows that S is non-empty. We can now apply the WOP to show that S has a least
element.
Every non-empty subset of positive integers has a least element.
WOP implies that there exists a least element of the set S, say r, which is of course an
integer. We have r is a member of the set S, and furthermore it is the smallest number in
the set S, which implies there exists an integer m = q such that
r = a − mb = a − qb ≥ 0.
Showing that r is in the set is only part of the task; we also need to show that r < b.
How?
By contradiction, suppose r ≥ b.
So r − b ≥ 0, which implies it is in S and we are given that b ≥ 1, therefore
r − b < r.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
D I V I S I O N A LG O R I T H M ( 1 1 – 1 7 ) 15
But r is the smallest element of S and we have found a smaller element, r − b, which is also
in S, meaning we have a contradiction. Our supposition r ≥ b must be wrong, therefore
r < b. Hence 0 ≤ r < b.
(2) Uniqueness
We already have
a = bq + r 0 ≤ r < b. (∗∗)
0 = b(q − q′ ) + (r − r ′ )
r ′ − r = b(q − q′ )
r′ − r
= q − q′ (1)
b
WLOG, assume that r ′ ≥ r. By the inequalities of (∗) and (∗∗) we have 0 ≤ r ′ − r < b and
we are given that b ≥ 1. Therefore, substituting this 0 ≤ r ′ − r < b into equation (1), we
have
r′ − r b
0≤ < = 1.
b b
r′ − r
From (1) we also have = q − q′ and q − q′ is an integer, therefore
b
0 ≤ q − q′ < 1.
q − q′ = 0 ⇒ q = q′ .
Substituting this q − q′ = 0 into equation (1) gives r ′ = r, thus we see that both q and r are
unique.
We have proved not only that both q and r exist, but also that they are unique. This com-
pletes the proof of the Division Algorithm.
The Division Algorithm can also be applied to algebraic expressions in order to prove cer-
tain statements about integers, as the following examples demonstrate.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
16 1 A SURV EY OF D I V I S I B I L I T Y
Example 1.11
Show that the square of any integer is of the form 3m or 3m + 1 where m is an integer.
Solution
Let n be any integer.
How do we prove this result?
By applying the Division Algorithm (1.7):
For a and b there exist integers q and r such that a = bq + r where 0 ≤ r < b.
With b = 3 we can write any integer a = n as:
n = 3q + r where 0 ≤ r < 3.
2
n2 = (3q + r) = 9q2 + 6qr + r 2
=
⏟ 3 (3q2 + 2qr) + r 2 = 3k + r 2 where k = 3q2 + 2qr.
Factorizing
n2 = 3k, 3k + 1, and 3k + 4
= 3k, 3k + 1, and 3 (k + 1) + 1.
Note that n2 = 3 (integer) , 3 (integer) + 1, which says that any square number is of the form 3m or
3m + 1 where m is an integer.
Example 1.12
Show that the cube of any integer can only take one of the following forms:
9k, 9k + 1 or 9k + 8.
Solution
How do we show this result?
In the same manner as Example 1.11 by using the Division Algorithm (1.7):
For a and b there exist integers q and r such that a = bq + r where 0 ≤ r < b.
n = 9q + r where 0 ≤ r < 9.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
D I V I S I O N A LG O R I T H M ( 1 1 – 1 7 ) 17
Taking the cube of this by using the binomial theorem (see Introductory Chapter) or expanding by
multiplying out,
3 3 2
n3 = (9q + r) =
⏟ (9q) + 3 (9q) r + 3 (9q) r 2 +r 3 = 9k + r 3 .
⏟⎵⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⎵⏟
By binomial = 9k where k is an integer
Since 0 ≤ r < 9 and r is an integer, it can only take the following values:
r = 0, 1, 2, 3, ⋯ , 7, and 8.
03 = 0 = 0 (9) + 0 gives r ′ = 0
13 = 1 = 0 (9) + 1 gives r ′ = 1
23 = 8 = 0 (9) + 8 gives r ′ = 8
33 = 27 = 3 (9) + 0 gives r ′ = 0
43 = 64 = 7 (9) + 1 gives r ′ = 1
53 = 125 = 13 (9) + 8 gives r ′ = 8
63 = 216 = 24 (9) + 0 gives r ′ = 0
73 = 343 = 38 (9) + 1 gives r ′ = 1
83 = 512 = 56 (9) + 8 gives r ′ = 8.
We see that r 3 can only have remainder values 0, 1, and 8 after dividing by 9. Hence the cube of any
integer has the form
n3 = 9k + r 3 = 9k, 9k + 1 or 9k + 8.
Example 1.13
Solution
By the hint, every square is of the form 3k or 3k + 1.
First consider the case where the square is of the form 3k.
Suppose 3a2 − 1 is a square number. Then
3a2 − 1 = 3k
3 (a2 − k) = 1.
18 1 A SURV EY OF D I V I S I B I L I T Y
To close this statement, we extend the Division Algorithm (1.7) to a more general case
where we no longer require that b ≥ 1, but rather that b ≠ 0. This is given in Corollary (1.8)
below. A corollary is a result that follows from the main theorem or proposition. Generally,
it is a special case of the main result (see Introductory Chapter).
Corollary (1.8). Given any integers a and b with b ≠ 0, there exist unique integers q and r
such that
a = bq + r where 0 ≤ r < |b| .
Proof.
See Exercises 1.2, question 7.
Summary
Suppose we have any integers a and b ≥ 1, then there are unique integers q and r such that
a = bq + r where 0 ≤ r < b.
EXERCISES 1.2
(Brief solutions at end of book. Full 3. Prove by using the Division Algorithm
solutions available at <http://www.oup.co. that the fourth power of any integer is of
uk/companion/NumberTheory>.) the form 8k or 8k + 1.
1. Determine the quotient and remainder 4. Prove that for any integer a we have
in applying the Division Algorithm to 6 (a3 + 5a).
the following:
5. (i) Prove that 7 (a6 − 1) for any integer
(a) 31 divided by 4 a such that gcd (a, 7) = 1.
(b) −1001 divided by 12 (ii) Prove that for any integer a we have
(c) −10 001 divided by 137
7 (a7 − a).
2. Show that the square of any integer
6. Prove that for any integer a we have
looks like 4m or 4m + 1.
11 (a11 − a).
7. Prove Corollary (1.8).
.........................................................................................................
E U C L I D E A N A LG O R I T H M ( 1 8 – 2 9 ) 19
Say we want to evaluate the gcd of 5291 and 3108; finding the common divisors of these
numbers is going to be cumbersome. We need to develop an efficient way to find the gcd of
such numbers (see Example 1.17 later in this section).
We introduce the Euclidean Algorithm, which provides an efficient way to find the gcd
of two integers. Computers use the Euclidean Algorithm or Stein’s Algorithm1 to evaluate
the gcd of two integers.
We begin by looking at equations of the form
Example 1.14
In Example 1.8 we found gcd (36, 60) = 12. Let us solve for integers x and y in
Solution
We have a linear equation with two unknowns.
How can we solve this equation?
First, we divide through by 12, as it is a common factor. This simplifies to
3x + 5y = 1.
1 − 3 (2)
y= = −1.
5
There are going to be many other pairs of x and y which work.
We can also solve the equation using graphs because 36x + 60y = 12 is equivalent to
1 − 3x
y= (see Example 1.14), which is a straight line as shown in Figure 1.2. As you
5
can observe from the graph, there are two integer points (pairs) which are on the line
36x + 60y = 12. For instance, we found the point (2, −1) in Example 1.14, but we could
also have found the solution x = −3, y = 2 which is the point (−3, 2).
Indeed, there are an infinite number of integer points on the line 36x + 60y = 12. This
leads us to ask:
1
https://en.wikipedia.org/wiki/Binary_GCD_algorithm.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
20 1 A SURV EY OF D I V I S I B I L I T Y
4
36x + 60y = 12
2
(–3, 2)
x
–4 –2 2 4
(2, –1)
–2
–4
Figure 1.2 The graph shows two integer solutions to 36x + 60y = 12.
Can we always find integers x and y such that ax + by = g where g = gcd (a, b)?
We will show in the next section that integers of the form ax + by are multiples of the
gcd (a, b) (see Proposition (1.17) and Exercises 1.3, question 10).
Proof.
Common Divisor
Consider the set S given by
Why?
Let the integers x = a and y = b (we select these integers so that ax + by > 0), then
ax + by = a2 + b2 > 0 [Because a and b are not both zero].
Therefore S is non-empty, so by WOP:
Every non-empty subset of positive integers has a least element.
Let d be the least element of the above set S.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
E U C L I D E A N A LG O R I T H M ( 1 8 – 2 9 ) 21
ax + by = d. (∗)
To show that d is a common divisor of a and b, we make use of the Division Algorithm (1.7)
of the last section:
For integers m and n there exist q and r such that m = qn + r where 0 ≤ r < n.
We start by showing that d is a divisor of a by applying the Division Algorithm (1.7):
a = qd + r 0 ≤ r < d. (†)
r = a − qd.
S = {ax + by ∶ ax + by > 0} .
But if r is in the set, then from (†) we have r < d. This is impossible because d is the least
element of S. Therefore our supposition r > 0 is wrong, which implies r = 0, and so a = qd,
which implies d a.
Similarly, by applying the Division Algorithm to integers b and d we can show that d b.
Hence d is a common divisor of a and b.
It follows that as c d where c and d are both positive, so c ≤ d, which implies d must be the
greatest common divisor, gcd, of integers a and b. That is, d = gcd (a, b).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
22 1 A SURV EY OF D I V I S I B I L I T Y
Proof.
See proof of Bézout’s Identity (1.9).
Proposition (1.11). Let gcd (a, b) = g. For any positive integer m we have
Proof.
See Exercises 1.3, question 17.
We encountered the idea of two numbers being relatively prime back in Section 1.1. The
two integers 10 and 21 are relatively prime as they have no factor in common apart from 1.
The formal definition is:
Definition (1.12). Integers a and b not both zero are relatively prime (sometimes called
coprime) if
gcd (a, b) = 1.
Another example of relatively prime numbers is 5 and 13 because gcd (5, 13) = 1.
An important result concerning relatively prime numbers is Euclid’s Lemma. It is worth
learning this result, as it is used throughout number theory. Usually lemma means an in-
termediate result, or a result used to deduce an important theorem or proposition, but in
this case Euclid’s Lemma is a critical result in its own right. See Introductory Chapter for
an explanation of Lemma.
E U C L I D E A N A LG O R I T H M ( 1 8 – 2 9 ) 23
Example 1.15
Solution
Since gcd (13, 5) = 1, so by Euclid’s Lemma (1.13) we have 13 1 604 938 257.
Proof.
By Bézout’s Identity (1.9) given earlier:
if gcd (a, b) = g then there are integers m and n such that ma + nb = g,
there are integers m and n such that
Now we are given that a (bc), therefore there is an integer k such that
ak = bc.
24 1 A SURV EY OF D I V I S I B I L I T Y
How are we going to find the greatest common divisor of 5291 and 3108?
Listing the divisors of each and looking for divisors which are common to both numbers will
take considerable time. We need a simpler approach—the Euclidean Algorithm. Generally
the Euclidean Algorithm is an extremely fast and efficient way of finding the gcd of two
integers because it just uses repeated division and subtraction and removes the need to find
all the factors of the two given integers. It is quicker and less tedious than finding all the
factors, especially if the integers are large.
Next, we describe the Euclidean Algorithm which is based on the repeated application of
the Division Algorithm (1.7) of the last section:
For integers a and b there exist q and r such that a = bq + r where 0 ≤ r < n.
We repeatedly apply the Division Algorithm to the two given integers a and b; the gcd of
these given integers a and b turns out to be the last non-zero remainder, as the next example
demonstrates.
Example 1.16
Solution
We underline the remainder at each step for clarity.
The remainder is 15 which is non-zero, so we apply the Division Algorithm to 31 and 15:
31 = 2 (15) + 1.
Again, the remainder 1 is non-zero, so we continue to apply the Division Algorithm to 15 and 1:
15 = 15 (1) + 0.
2. If the remainder r1 = 0, then a = bq1 and gcd (a, b) = gcd (bq1 , b) = b. This means
we are done because we have found gcd (a, b) = b.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
E U C L I D E A N A LG O R I T H M ( 1 8 – 2 9 ) 25
b = r1 q2 + r2 where 0 ≤ r2 < r1 .
4. If the remainder r2 = 0, then we are done. Otherwise we repeat the above process of
applying the Division Algorithm to r1 and r2 . We continue in this manner until we
get a remainder of zero.
5. The last non-zero remainder is the gcd of the given integers a and b.
We will prove step 2 below. However, prior to the proof of this we will demonstrate the
Euclidean Algorithm with an example.
Example 1.17
5291
By applying the Euclidean Algorithm, find gcd (5291, 3108) and simplify .
3108
Solution
Dividing 5291 by 3108 gives 5291 = 1 (3108) + 2183.
Since we do not have a zero remainder, we continue to apply the Division Algorithm until we get a
zero remainder:
5291
How can we simplify the given fraction ?
3108
By Proposition (1.5) of Section 1.1:
a b
If gcd (a, b) = g then gcd ( , ) = 1.
g g
This implies that dividing the numerator 5291 and denominator 3108 by 37, which is the gcd, gives no
factors in common (apart from 1) after division. Therefore,
26 1 A SURV EY OF D I V I S I B I L I T Y
Thus 143/84 is the simplest fraction of 5291/3108, because by Proposition (1.5) we have
gcd (143, 84) = 1. So these numbers (143 and 84) are relatively prime.
We need to prove that the gcd of given integers a and b is equal to the gcd of b and r where
r is the remainder when we divide a by b. [This was step 2 of the Euclidean Algorithm.]
Proposition (1.14). If
a = bq + r where 0 ≤ r < b,
then g = gcd (a, b) = gcd (b, r).
Proof.
Let g1 = gcd (a, b) and g2 = gcd (b, r). We need to prove that g1 = g2 .
Similarly, repeating the above process with g2 = gcd (b, r) we can deduce that
g2 ≤ g1 .
Hence g1 = g2 .
We can use the Euclidean Algorithm in reverse order to solve linear equations like
This is an example of a Diophantine equation, which we will describe in the next section.
In Example 1.16 we found gcd (666, 31) = 1. Thus this linear equation is
666x + 31y = 1.
Why?
Drawing the graph of this straight line 666x + 31y = 1 is shown in Figure 1.4 on the next
page.
Any point on this straight line is a solution to 666x + 31y = 1. However, we are only
interested in integer solutions to this equation.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
E U C L I D E A N A LG O R I T H M ( 1 8 – 2 9 ) 27
y
100
50
666x + 31y = 1
x
–4 –2 2 4
–50
–100
Figure 1.4 The graph shows an integer solution of the line 666x + 31y = 1.
1 = 31 − 2 (15)
= 31 − 2 (666 − 21 (31)) [By (∗)]
= 31 − 2 (666) + 42 (31) [Expanding the brackets]
= 43 (31) − 2 (666) [Collecting like terms] .
Clearly x = −2 and y = 43. This is the point shown on the above graph in Figure 1.4. (This
is just one of infinitely many integer solutions.)
Example 1.18
Solution
What are we trying to find?
The integer values of x and y which satisfy the given equation. We have already found the gcd of 5291
and 3108 in Example 1.17. We had the following (step numbers have been added):
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
28 1 A SURV EY OF D I V I S I B I L I T Y
37 was the last non-zero remainder, so gcd (5291, 3108) = 37. We use these six steps in reverse order
to obtain integer values of x and y such that
37 = 259 − 3 (74)
= 259 − 3 (333 − 259) [Using step (5)]
= 4 (259) − 3 (333) [Collecting like terms]
= 4 (925 − 2 (333)) − 3 (333) [Using step (4)]
= 4 (925) − 11 (333) [Collecting like terms]
= 4 (925) − 11 (2183 − 2 (925)) [Using step (3)]
= 26 (925) − 11 (2183) [Collecting like terms]
= 26 (3108 − 2183) − 11 (2183) [Using step (2)]
= 26 (3108) − 37 (2183) [Collecting like terms]
= 26 (3108) − 37 (5291 − 3108) [Using step (1)]
= 63 (3108) − 37 (5291) [Collecting like terms]
What can you say about the linear equation 5291x + 3108y = 36?
It has no integer solutions because the least value of this linear combination 5291x + 3108y
is 37.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
E U C L I D E A N A LG O R I T H M ( 1 8 – 2 9 ) 29
Note that by applying the Euclidean Algorithm we can find the gcd of any two positive
integers, a and b, plus solve the linear equation
ax + by = gcd (a, b)
Summary
We use the Euclidean Algorithm to find the gcd of two numbers, a and b. By reversing the steps of the
Euclidean Algorithm we can solve the linear equation ax + by = gcd (a, b).
EXERCISES 1.3
(Brief solutions at end of book. Full 5. Given that gcd (a, b) = 1 and integers
solutions available at <http://www.oup.co. x0 and y0 are solutions to ax + by = 1,
uk/ companion/NumberTheory>.) determine an integer solution
to ax + by = c where c is an
1. By using the Euclidean Algorithm
integer.
determine:
6. Show that there is no integer solution
(a) gcd (156, 18) (b) gcd (129, 1011)
to the linear equation
(c) gcd (703, 111) (d) gcd (181, 232)
20x + 28y = 2.
2. Find a particular integer solution to
the linear equations: 7. Explain why there are no positive
(a) 156x + 18y = gcd (156, 18) integer solutions to
(b) 129x + 1011y = gcd (129, 1011) 5x + 6y = 1.
(c) 703x + 111y = gcd (703, 111)
[Hint: Sketch a graph.]
(d) 181x + 232y = gcd (181, 232)
8. Suppose 198 5x. Show that 198 x.
3. Determine the least positive integer
values of the following linear 9. Find different negative integers a and b
combinations (x and y are which satisfy the following:
integers):
(a) gcd (a, b) = 5
(a) 132x + 174y (b) 102x + 207y (b) gcd (a, b) = 100
(c) 99x + 1008y (d) 666x + 3020y (c) gcd (a, b) = 169
4. Find integers x and y in each of the 10. Prove that if there are integers x and y
following cases: such that ax + by = n then g n where
g = gcd (a, b).
(i) 314x + 785y = 157
(ii) 314x + 785y = 314 11. Prove that if integers a ≠ 0 and b such
(iii) 314x + 785y = −1570 that a b then gcd (a, b) = |a|.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
30 1 A SURV EY OF D I V I S I B I L I T Y
gcd (a, b) = gcd (a, c) = 1 gcd (a, b, c) = gcd (a, gcd (b, c))
⇔ gcd (a, bc) = 1.
where a, b, c are non-zero.
.........................................................................................................
1.4.1 Introduction
2
https://www.youtube.com/watch?v=BVtQNK_ZUJg.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 31
The telephone message to Bruce Willis said that the only way to defuse the bomb was to
place exactly four gallons of water on the pressure-sensitive pad.
How can we get exactly four gallons of water with only three- and five-gallon containers?
4 − 5x
5x + 3y = 4 ⇒ y = [Transposing] .
3
We are only interested in integer solutions (whole gallons); with a bit of guesswork we try
x = 2, which gives
4 − 5x 4 − 5 (2)
y= = = −2.
3 3
This solution, x = 2 and y = −2, means that we fill the five-gallon container twice (x = 2)
and empty out the three-gallon container twice (y = −2). See Figure 1.5 for an illustration
of this:
5 gallons 1 gallon
4 gallons
3 gallons
2 gallons
Figure 1.5
32 1 A SURV EY OF D I V I S I B I L I T Y
Definition (1.15). A general linear Diophantine equation with two variables is of the form
ax + by = c where the variables x and y are integers and both integers a and b are not zero.
Example 1.19
Solution
4 − 5x
From the previous page we have y = . By trial and error, let x = 5, then
3
4 − 5x 4 − 5 (5)
y= = = −7.
3 3
Hence x = 5 and y = −7 is another solution to 5x + 3y = 4. Check this.
Yes. Let’s start with our first x solution, which we will call x0 . So x0 = 2 (on the previous
page) and we can write the general x solution as 2 plus any extra integer, say t, that will also
work as a solution to 5x + 3y = 4:
x = 2 + t where t is an integer.
4 − 5x
Substituting this x = 2 + t into y = gives
3
4 − 5 (2 + t) 4 − 10 − 5t −6 − 5t 5
y= = = = −2 − t.
3 3 3 3
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 33
Example 1.20
Suppose in the Die Hard problem we had three-gallon and six-gallon containers and we wanted to
place exactly five gallons of water on the sensitive pad.
How is this possible?
Solution
We first formulate the problem. Let x and y be the number of times we fill the three- and six-gallon
containers respectively. We have the Diophantine equation
3x + 6y = 5.
5 − 3x 5 1
y= = − x.
6 6 2
If x is a multiple of 2 then y would still not be an integer because we would have to add 5/6.
By the previous section on the Euclidean Algorithm we know we have solutions if we have
We can also solve for any multiple of g, which means we can find integer solutions for
ax + by = mg.
For the given equation 3x + 6y = 5 the gcd of 3 and 6 is 3, but the right-hand side 5 is not a multiple
of 3.
Actually, we will show later that the given equation has no solutions.
Hence it is impossible to measure five gallons of water with only three- and six-gallon containers.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
34 1 A SURV EY OF D I V I S I B I L I T Y
In this case, the straight line 3x + 6y = 5 never crosses an integer grid point:
2
3x + 6y = 5
x
–10 –8 –6 –4 –2 2 4 6 8 10
–2
–4
Figure 1.7 Note the line 3x + 6y = 5 misses the integer grid points.
None of the points (x, y) on this line have both x and y integer entries. This means that
the Diophantine equation 3x + 6y = 5 has no solution, because for Diophantine equations
we are only interested in integer solutions.
ax + by = c.
Then x = x0 + bt and y = y0 − at, where t is any integer, is also a solution to this equation.
(The Die Hard problem gave the solution x = 2 + 3m, y = −2 − 5m.)
Proof.
As we are given that x0 and y0 is a solution to ax + by = c, therefore we have
As t can be any integer in the above, x = x0 + bt and y = y0 − at, so we have infinitely many
solutions to ax + by = c provided we have some initial solution x0 and y0 .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 35
Example 1.21
30x + 29y = 1.
Solution
Clearly gcd (30, 29) = 1. By trial and error our solution is
x0 = 1 and y0 = −1.
t x = 1 + 29t y = −1 − 30t
1 x = 1 + 29 = 30 y = −1 − 30 = −31
2 x = 1 + (29 × 2) = 59 y = −1 − (30 × 2) = −61
3 x = 1 + (29 × 3) = 88 y = −1 − (30 × 3) = −91
−1 x = 1 + 29 (−1) = −28 y = −1 − 30 (−1) = 29
−2 x = 1 + 29 (−2) = −57 y = −1 − 30 (−2) = 59
You may like to check that each of these x and y values satisfies the given equation
30x + 29y = 1.
As t can take on any integer value, we have infinitely many solutions to the given equation,
30x + 29y = 1.
Figure 1.8 on the next page shows the x, y values from the above table plotted on a graph. We see that
the line 30x + 29y = 1 intersects all these points, showing that they are solutions to the equation.
Proposition (1.17). Let gcd (a, b) = g. The Diophantine equation ax + by = c has integer
solutions ⇔ g c.
36 1 A SURV EY OF D I V I S I B I L I T Y
y
(–57, 59)
50
30x + 29y = 1
(–28, 29)
x
–60 –40 –20 20 40 60 80
(30, –31)
–50 (59, –61)
Proof.
(⇒). We assume ax + by = c has integer solutions and then deduce g c.
Suppose there are integers x and y such that ax + by = c. Since gcd (a, b) = g, so g a and
g b. By Proposition (1.3):
If c a and c b then c| (ax + by) for any integers x and y.
Applying this Proposition (1.3) to g a and g b gives
g (ax + by) .
(⇐). For this part, we assume g c and deduce ax + by = c has integer solutions.
Consider the linear equation
ax + by = g.
By Bézout’s Identity (1.9) of the last section:
If gcd (a, b) = g then there are integers x and y such that ax + by = g.
Let us nominate these integers x0 and y0 . Therefore,
Now consider the given equation ax + by = c. [This time on the right-hand side we have c
instead of g.]
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 37
ax0 m + by0 m = ⏟⎵ 0 + by
(ax⎵⏟⎵ ⎵⏟0 ) m = gm = c.
=g by (†)
Note that this proposition is also saying that if g does not divide c, in symbolic notation
g c, then ax + by = c has no integer solutions. The Diophantine equation of Example 1.20,
3x + 6y = 5,
Example 1.22
Solution
In each case we use the previous Proposition (1.17); check that gcd (a, b) divides c.
(a) The gcd (5, 10) = 5 and 5 3, so by the previous Proposition (1.17)
(b) Similarly, gcd (4, 12) = 4 but 4 14, so the given equation 4x + 12y = 14 has no integer
solutions.
(c) We have gcd (21, −35) = 7 and 7 (−7), so 21x − 35y = −7 has solutions.
(d) Also gcd (108, 99) = 9 and 9 45, so 108x + 99y = 45 has solutions.
Proposition (1.17) only tells us whether there is a solution, but does not give us the
solution. The next proposition stipulates how we can find integer solutions to a linear
Diophantine equation from an initial solution.
Proposition (1.18). Let gcd (a, b) = g. If g c and x0 , y0 are particular solutions of the
equation
ax + by = c,
then all the other solutions of this equation are given by
b a
x = x0 + ( ) t and y = y0 − ( ) t where t is any integer.
g g
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
38 1 A SURV EY OF D I V I S I B I L I T Y
Proof.
Let x ′ and y ′ be a solution of ax + by = c. Therefore, we have
ax ′ + by ′ = c.
Since we are given that x0 , y0 are solutions, so ax0 + by0 = c. Equating these last two equa-
tions because both are equal to c yields
ax ′ + by ′ = ax0 + by0 = c.
a (x ′ − x0 ) = b (y0 − y ′ ) .
a b
if gcd (a, b) = g then gcd ( , ) = 1,
g g
a b
we have gcd ( , ) = 1. Applying Euclid’s Lemma (1.13):
g g
a ′ b a
(x − x0 ) = ( t) .
g g g
a
Cancelling from both sides yields
g
b b
x ′ − x0 = t implies x ′ = x0 + t = x.
g g
This completes our proof.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 39
Example 1.23
Solution
Applying the Euclidean Algorithm to 35 and 30 gives
35 = 30 + 5
30 = 6 (5) + 0.
Therefore, gcd (30, 35) = 5. Since 5 565, so the given equation 30x + 35y = 565 has integer
solutions.
Re-arranging the above gives 35 − 30 = 5.
We can solve the equation 30x1 + 35y1 = 5 because 30 (−1) + 35 (1) = 5, so
x1 = −1 and y1 = 1.
b a
x = x0 + ( ) t and y = y0 − ( ) t
g g
b 35
x = x0 + ( ) t = −113 + ( ) t = −113 + 7t and
g 5
a 30
y = y0 − ( ) t = 113 − ( ) t = 113 − 6t.
g 5
The general solution of the given equation 30x + 35y = 565 is x = 7t − 113 and y = 113 − 6t where t
is any integer.
(You can select particular values of t to find particular solutions. For example, substituting t = 0 into
the above gives our initial solution x0 = −113 and y0 = 113.)
In a real-life problem, we generally need to restrict the values of the variables. For exam-
ple, the variables x and y may need to be positive. We place a restriction on our integer t,
which produces positive x and y values.
By inequalities. You will need to know how to solve inequalities for the next example. They
were discussed in the Introductory Chapter.
Example 1.24
A bookstore places a total order of £565 on two kinds of books. A softback book costs £30 and a
hardback book costs £35.
How many hardback and softback books were ordered?
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
40 1 A SURV EY OF D I V I S I B I L I T Y
Solution
Formulating the equation gives
30x + 35y = 565
where x and y are the number of softback and hardback books ordered respectively.
This is the Diophantine equation of the previous example and we found the general solution to be
113
7t − 113 ≥ 0 ⇔ 7t ≥ 113 ⇔ t ≥ = 16.14 (2dp).
7
Similarly,
113 113
113 − 6t ≥ 0 ⇔ 113 ≥ 6t ⇔ ≥ t or t ≤ = 18.83 (2dp) .
6 6
Hence t is an integer between 16.14 and 18.83.
What integer values can t take?
t = 17 or t = 18. Substituting t = 17 into x = 7t − 113 and y = 113 − 6t gives
Substituting the other integer value t = 18 into x = 7t − 113 and y = 113 − 6t gives
We have two solutions: x = 6, y = 11 or x = 13, y = 5. This means we have either ordered six soft-
back and 11 hardback books or 13 softback and five hardback books.
Note that in the Die Hard problem the integers x and y could be negative (pour out) as well
as positive (fill) and zero (empty). Any restriction on the integers x and y in a Diophantine
equation depends on the practical problem. For example:
Suppose you go shopping to buy some hotdogs and buns. If we let x and y be the
number of hotdogs and buns respectively then these variables must be positive or zero,
as we can’t leave the shop with a negative number of buns or hotdogs.
Next we state how to find solutions of a special Diophantine equation ax + by = c where
a and b are relatively prime.
Corollary (1.19). Let gcd (a, b) = 1 (relatively prime) and x0 , y0 be particular solutions of
the equation
ax + by = c.
Then all the other solutions of this equation are given by x = x0 + bt and y = y0 − at where
t is any integer.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 41
Proof.
See Exercises 1.4, question 10.
Summary
An example of a two-variable linear Diophantine equation is
ax + by = c.
We say this equation has a solution if there are integers x and y which satisfy this equation.
There exist solutions to this equation provided g c where gcd (a, b) = g. The general solution of
b a
this equation is given by x = x0 + ( ) t and y = y0 − ( ) t where t is any integer and x0 , y0 are
g g
particular solutions.
EXERCISES 1.4
(Brief solutions at end of book. Full purchase with £20, leaving no change.
solutions available at <http://www.oup.co. You must buy at least one of each.
uk/companion/NumberTheory>.)
5. Suppose in the Die Hard problem we
1. Find the general solution have four- and five-gallon containers
of the following Diophantine and we want to measure exactly three
equations: gallons. How can we do this?
(a) 2x + 3y = 5 6. Assume there are one hundred pence
(b) 3x + 6y = 9 in the pound (£). Using just 5p (£0.05)
(c) 15x − 20y = 10 and 10p (£0.10) pieces, how many of
each do you need in order to pay a
2. Determine whether the following
parking meter charge of £3.10.
equations have integer solutions. If
they do have solutions, find the general 7. Assume there are one hundred pence
solution: in the pound (£). First-class stamps
cost 60p (£0.60) and second-class
(a) 2x + 4y = 1
stamps cost 50p (£0.50) each.
(b) 48x + 56y = 32
What combination(s) of stamps can
(c) 54x + 180y = −72
you get for exactly £50, leaving no
3. Solve the following Diophantine change?
equations for general solutions, if
8. Each hotdog costs £0.24 and each bun
possible:
costs £0.14. List the combination(s) of
(a) 101x + 600y = 1001 hotdogs and buns that can be
(b) 181x + 232y = −100 purchased with exactly £5.
[For (b) see Exercises 1.3, 9. An ATM machine distributes £10 and
question 2 (d).] £20 notes. If you ask for £100, what
possible combinations of £10 and £20
4. A collection of bars costs £2 and a
notes can you get?
collection of rolls costs £3. List the
number of bars and rolls you can 10. Prove Corollary (1.19).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
42 1 A SURV EY OF D I V I S I B I L I T Y
11. Prove that ax + by = 1 has integer 15. Let a ≠ 0 and consider the linear
solutions ⇔ gcd (a, b) = 1. equation ax + may = na. Prove that if
x0 , y0 is a particular solution of this
12. Let gcd (a, b) > 1. Show that the
equation then the general solution
equation ax + by = 1 has no solutions.
is given by x = x0 + mt and
13. Show that 45x + 81y = 1 has no y = y0 − t.
solutions.
16. Prove or disprove the following
14. Prove the following result: statements:
Let gcd (a, b) = 1 and a positive (a) If d a and d b, then the
integer k divides c. Let x0 , y0 be Diophantine equation ax + by = c
particular solutions of the equation has solutions.
akx + bky = c. (b) If d a, d b and d c, then the
Then all the other solutions of this Diophantine equation ax + by = c
equation are given by has solutions.
b a (c) The Diophantine equation
x = x0 + ( ) t and y = y0 − ( ) t
k k ax + (a + 1) y = 1 has solutions.
where t is any integer.
.........................................................................................................
Supplementary Problems 1
L I N E A R D I O P H A N T I N E E Q UAT I O N S ( 3 0 – 4 3 ) 43
..............................................................................................................................
The aim of this chapter is to discuss primes, which are essential to understanding positive
integers. In this chapter we prove the Fundamental Theorem of Arithmetic which says that
every positive integer greater than 1 can be factorized into primes in a unique way. The
Fundamental Theorem of Arithmetic does not provide the factorization of the given integer,
but just stipulates that a factorization does exist.
In Section 2.2 we will show a technique of how to factorize a given integer into its primes.
We also discuss unsolved problems regarding the primes and examine their distribution in
Section 2.3.
We finish this chapter by establishing a technique for finding the least common multiple,
LCM, and gcd of two given integers. This technique relies on us first converting the given
integers into primes.
Number theory is the study of integers, particularly the study of positive integers. Prime
numbers are central to this.
Definition (2.1). An integer p greater than 1 is called a prime number, or prime if its only
divisors are 1 and p. An integer greater than 1 that is not prime is called composite.
This definition implies that every integer greater than 1 is either a prime or a composite
number.
Examples of prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, . . .
Examples of composite numbers are 4, 6, 8, 9, 10, 12, 14, 15, . . .
Note that the only even prime is 2.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
46 2 P R IM ES A ND FAC TO R I Z AT I O N
For over 4000 years, number theory had no serious application. Then in the 1970s with
the advent of the digital computer came lots of applications for number theory. One such
application is the encryption of messages—the protection of messages so that they can only
be read by the recipient. This study of secure communication is called cryptography.
Encrpytion Decyption
Public-key encryption transforms a text message into something which makes no sense,
mostly changing letters to numbers by using a public key. The message is transformed back
to the original message by a private key and this process is called decryption.
These keys are large numbers.
It is easy to multiply two large primes, p and q, to get a new number, n, that is n = p × q.
However, it is very difficult to go the other way, that is, given n, to factorize it into its large
prime factors p × q.
For example, multiplying the two primes 23 456 761 and 9 876 543 139 gives
23 456 761 × 9 876 543 139 = 231 671 711 917 712 779.
However, factorizing the right-hand side—231 671 711 917 712 779—is a difficult task un-
less you know the above primes give this answer.
Consider the following analogy: imagine there are thousands of different-coloured paint
cans and we mix two different-coloured paints. If we asked someone which two colours
were mixed by just showing them the final paint can, they would find it very difficult to
tell us.
Decrypting the message relies on factorizing the number n into two large prime factors,
p and q.
Yes. Cicadas are insects which hibernate underground. Scientists believe that their lifecycle
has evolved in a way that allows them to minimize encounters with predators. They emerge
every 13 or 17 years. Once out of hibernation they mate and die, while the newborn cicadas
head for underground hibernation.
They have one shot at breeding and then they die.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I NT R O D U C T I O N TO P R I M E S ( 4 5 – 5 3 ) 47
If the cicadas emerged every eight years, then the predators with lifespans of one, two,
four, and eight years will coincide with the availability of cicadas. This could drive the
cicadas to extinction. Having a prime number of years of hibernation (13 or 17) ensures
predators are less likely to catch them.
The Fundamental Theorem of Arithmetic is one of the most important results in mathe-
matics and claims the following:
Every integer greater than 1 is either a prime or a product of primes which is written
uniquely apart from the order.
We will prove this later in this section.
Examples of this are:
The Fundamental Theorem of Arithmetic says that the factorization of an integer greater
than 1 into primes is unique apart from the order.
If we consider 100 = 22 × 52 , then 2 and 5 are the only primes which when multiplied to-
gether several times give 100. There are no other primes in the factorization of 100. Of
course, we can write
100 = 22 × 52 = 2 × 2 × 52 = 5 × 5 × 2 × 2 = . . .,
but this just changes the order of multiplication. The prime numbers 2 and 5 are the building
blocks of 100 (see Figure 2.2).
100
22 52
2 2 5 5
Figure 2.2
This fundamental theorem says that every integer greater than 1 is either a prime number
or can be made up by a product of primes. This means that primes are the building blocks
of the positive integers.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
48 2 P R IM ES A ND FAC TO R I Z AT I O N
Now we examine the divisors or factors of a positive integer greater than 1. For example
(recall from Chapter 1, a b implies a is a divisor of b):
2 364 implies that 2 (4 × 91) which implies 2 4.
Note that 2 is a prime number. Similarly, 7 is a prime and
7 98 ⇒ 7 (49 × 2) ⇒ 7 49.
In general, we have:
Proof.
If p a then we have our result.
Suppose prime p does not divide a, that is p a, then gcd (a, p) = 1.
Why?
Let gcd (a, p) = g, then g p but the only factors of p are 1 and p because p is prime. This
implies that g = p or g = 1.
Also g a because g is a common divisor of a and p, so g ≠ p [not equal] because we are
supposing p does not divide a. Hence
g = gcd (a, p) = 1.
Next, we prove a corollary which extends the above proposition. We can extend this
Proposition (2.2) to a product of more than two terms:
We can prove this result by using mathematical induction. Remember the three steps of
induction from the Introductory Chapter:
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I NT R O D U C T I O N TO P R I M E S ( 4 5 – 5 3 ) 49
Proof.
Step 1: With p (a1 × a2 ) we get p a1 or p a2 by Proposition (2.2).
Step 2: Assume the result is true for n = k:
Step 3: We are required to prove this result for n = k + 1, that is we need to prove that
p (a1 × a2 × a3 × ⋯ × ak ) × ak+1 .
p (a1 × a2 × a3 × ⋯ × ak ) or p ak+1 .
If the a’s in this Corollary (2.3) are prime then p is equal to one of the a’s. For example,
7 (p1 × p2 × ⋯ × pk ) then one of the p’s is equal to 7.
We can generalize this:
Proof.
We are given that p (q1 × q2 × q3 × ⋯ × qn ) where q’s are prime. Applying the previous
Corollary (2.3):
50 2 P R IM ES A ND FAC TO R I Z AT I O N
Note that this result (2.4) is not valid for composite divisors. For example,
6 (2 × 3 × 7) but 6 ≠ 2, 6 ≠ 3, and 6 ≠ 7.
Before we state and prove the Fundamental Theorem of Arithmetic we look at some nu-
merical examples so that we can have an intuitive appreciation of the existence of prime
factorization.
For example, the following shows the prime factors of various numbers:
360 = 2 × 2 × 2 × 3 × 3 × 5 = 23 × 32 × 5
1 000 000 = 26 × 56
1 000 001 = 101 × 9901
2 789 865 215 = 5 × 557 973 043.
We use the Well-Ordering Principle (WOP) and Without Loss of Generality (WLOG) to
prove the theorem and these were discussed in the Introductory Chapter.
Fundamental Theorem of Arithmetic (2.5). Every integer n greater than 1 is either a prime
or can be written uniquely as the product of primes apart from the order.
First, we prove that n is a product of primes and then we show that this representation is
unique apart from the order.
Proof.
Proof that n is a product of primes (Existence Proof):
Either n > 1 is prime or composite. If n is a prime, then we are done.
If n is composite then it has a divisor, say d > 1, which implies d n.
Let S be the set of positive divisors greater than 1 of n. Then S is non-empty because d is
in S as d n.
Amongst this set S of positive divisors there must be a smallest divisor, call this p1 , of n.
Why?
I NT R O D U C T I O N TO P R I M E S ( 4 5 – 5 3 ) 51
If n1 is prime, then we have shown that n is a product of primes and only need to prove
uniqueness.
If n1 is composite, then we can repeat the above process.
Let p2 be the smallest divisor of n1 and, as above, p2 must be prime. Hence p2 n1 , so
n1 = p2 × n2 where n2 is an integer.
n = p1 × p2 × n2 .
If n2 is prime, then we have our product of primes. If n2 is composite, then repeating the
above process we have
n = p1 × p2 × p3 × n3 .
This cannot continue forever because
(n has a finite number of prime divisors), there must be an integer, nk say, where nk is prime,
that is nk = pk . We have
n = p1 × p2 × p3 × ⋯ × nk = p1 × p2 × p3 × ⋯ × pk .
n = p1 × p2 × p3 × ⋯ × pr = q1 × q2 × q3 × ⋯ × qs (†)
where the p’s and q’s are prime and they are written in descending order, that is
p1 ≥ p2 ≥ p3 ≥ ⋯ ≥ pr and q1 ≥ q2 ≥ q3 ≥ ⋯ ≥ qs . (∗)
p1 (q1 × q2 × q3 × ⋯ × qs ) .
52 2 P R IM ES A ND FAC TO R I Z AT I O N
p1 , p2 , p3 , ⋯ , pr .
p1 = q1 .
p2 = q2 , p3 = q3 , p4 = q4 , . . . and pr = qr .
If s > r then by cancelling out the common factors—p1 with q1 , p2 with q2 , ⋯, and pr with
qr —in the multiplication p1 × p2 × p3 × ⋯ × pr = q1 × q2 × q3 × ⋯ × qs gives
1 = qr+1 × qr+2 × ⋯ × qs . [We get the 1 by cancelling out all the p’s.]
This is impossible because all the q’s are prime, and we have 1 = prime × prime × prime . . .
and the smallest prime is 2. This 1 = prime × prime × . . . is impossible.
Therefore, we have s = r which implies that
p1 = q1 , p2 = q2 , p3 = q3 , p4 = q4 , . . . , pr = qr .
120 = 2 × 2 × 2 × 3 × 5 = 23 × 3 × 5.
Corollary (2.6). Every integer n greater than 1 is either a prime or can be written uniquely
as a product of primes apart from the order:
n = p1 k1 × p2 k2 × p3 k3 × ⋯ × pr kr where p’s are distinct primes.
In the above n = p1 k1 × p2 k2 × p3 k3 × ⋯ × pr kr the primes pj , are distinct and the indices,
kj , are positive integers. This representation:
n = p1 k1 × p2 k2 × p3 k3 × ⋯ × pr kr
I NT R O D U C T I O N TO P R I M E S ( 4 5 – 5 3 ) 53
5 5
∏ (k) = 1 × 2 × 3 × 4 × 5 and ∏ (k2 ) = 12 × 22 × 32 × 42 × 52 .
k=1 k=1
Summary
A prime number is an integer greater than 1 with only factors of 1 and itself.
EXERCISES 2.1
(Brief solutions at end of book. Full 6. (a) Prove that consecutive integers
solutions available at <http://www.oup.co. have no prime factors in common.
uk/companion/NumberTheory>.)
(b) Prove that gcd (n, n + 1) = 1.
1. Write the prime decomposition of the
7. Evaluate the following products:
following numbers:
6 6 3 5
j i
(a) 56 (b) 57 (c) 200 (d) 360 (a) ∏(2j) (b) ∏( ) *(c) ∏ ∏( )
j=1 j=1 2 j=1 i=1 j
(e) 1001
2. Write the prime decomposition of the 8. Find the error in the following
following numbers: statements and give reasons for your
answers.
(a) 53 (b) 530 (c) 1988
(d) 666 (e) 2021 (a) 3 (−3 × (−5)) ⇒ 3 = −3.
(b) Prove that if p and q are distinct 9. Show that the integers p, p + 2 where p
primes then gcd (p, q) = 1. is an odd prime has no common factor
greater than 1. (Show p and p + 2 are
4. Show that the smallest factor greater relatively prime.)
than 1 of pn is the prime p.
10. Let p be prime. Show that one of p,
5. (i) Prove that if p and q are distinct p + 2, or p + 4 is divisible by 3.
primes then gcd (pn , qn )=1 for any
natural number n. 11. Disprove the following statements:
(ii) Prove that if p and q are distinct (a) If p is prime then p + 2 is prime.
primes then gcd (pn , qm ) = 1 for any (b) The integer n2 + 1 is prime for
natural numbers m and n. n = 2m.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
54 2 P R IM ES A ND FAC TO R I Z AT I O N
.........................................................................................................
As we get older we like to tell others that we are young. For example, if we are a day short
of our 52nd birthday, we might claim we are 51. This is an example of the floor function in
action. The floor function is defined as:
Definition (2.7). The floor function is denoted by ⌊x⌋ and is the greatest integer less than or
equal to x. We can write this in mathematical notation as:
T ESTI N G N U M B E R S F O R P R I M A L I T Y ( 5 4 – 6 3 ) 55
In the above example we apply the floor function to justify our age:
364
⌊51 ⌋ = ⌊51.997⌋ = 51.
365
Although 51.997 is closer to 52, when we take the floor function it is the largest integer less
than 51.997, which is 51.
Similarly, we have
⌊7⌋ = 7, ⌊𝜋⌋ = ⌊3.14 ⋯⌋ = 3, ⌊e⌋ = ⌊2.72 ⋯⌋ = 2, ⌊2.9999⌋ = 2, ⌊−2.1⌋ = −3.
Be careful when taking the floor function of a negative number, as you may have observed
that ⌊−2.1⌋ = −3. You take the nearest integer which is less than −2.1:
–2.1
–5 –4 –3 –2 –1 0
Integers less than –2.1
Figure 2.3 Integers less than −2.1 are to the left.
⌊100.9⌋ = 100,
56 2 P R IM ES A ND FAC TO R I Z AT I O N
y
5
4
3
2
1
x
–5 4 –3 –2 –1 –1 1 2 3 4 5
y = ⌊x⌋
–2
–3
–4
–5
Figure 2.4
Definition (2.8). The ceiling function, denoted ⌈x⌉, is the least integer greater than or equal
to x. In mathematical notation, this is written as:
Again, be careful with negative numbers. For the ceiling function of −2.1 we are looking at
integers greater than −2.1, so we move to the right of the number line and find the closest
integer to the right of −2.1, which is −2 (see Figure 2.3).
Applications of the ceiling function are:
1. Mobile phone companies use the ceiling function for the number of minutes a phone
call lasts. For example, if you make a call which lasts three minutes and one second
then you end up paying for four minutes because
1
⌈3 ⌉ = ⌈3.02⌉ = 4.
60
Note that 3.02 is closer to 3 than 4, but the ceiling function gives the next integer
greater than or equal to 3.02, which is 4.
2. Say you want to purchase 21 buns and they are sold in packages of four. You will need
to buy
21
⌈ ⌉ = ⌈5.25⌉ = 6 packages.
4
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T ESTI N G N U M B E R S F O R P R I M A L I T Y ( 5 4 – 6 3 ) 57
3. Say you go boating and the rate is £1.20 for every half hour. If you have 40 minutes
of boating, then you would have to pay for two lots of half an hour because
40
⌈ ⌉ = ⌈1.33 ⋯⌉ = 2.
30
You will end up paying 2 × 1.20 = £2.40.
The graph of the ceiling function is:
y
5
4
3
2
1
x
–5 –4 –3 –2 –1 –1 1 2 3 4 5
y = ⌈x⌉
–2
–3
–4
–5
Figure 2.5
It is important that you realize the difference between finding the floor or ceiling and round-
ing a number. For example,
Below we will show that a composite number n must have at least one factor which is less
than or equal to √n. For example, 10 = 2 × 5 is composite with factors 2 and 5. Evaluating
√10 = 3.16 (2dp) and one of the factors, 2, is less than 3.16. Since we are interested in
integers we take the floor function of this √10 = 3.16 (2dp) which is ⌊√10⌋ = 3 and factor
2 is less than 3.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
58 2 P R IM ES A ND FAC TO R I Z AT I O N
Proposition (2.9). (This tests a given integer for compositeness.) If n > 1 is composite then
it has a divisor, d, such that 1 < d ≤ ⌊√n⌋.
It implies that if n is composite then it must have at least one divisor >1 which is less than
or equal to ⌊√n⌋. Recall divisors and factors are synonymous.
Proof.
We are given that n is composite. This implies there exist integers d1 and d2 that satisfy
1 < d1 < n and 1 < d2 < n such that n = d1 × d2 .
Suppose divisor d1 > ⌊√n⌋. Since d1 is an integer we have d1 > √n.
Applying the rules of inequalities from the Introductory Chapter, we have
n n 1 1
d2 = < = √n. [Using y > x > 0 implies < .]
d1 √n y x
Note that this proposition says that to test whether a number is composite we only need
to look for divisors (factors) from 2 to ⌊√n⌋ (the floor function of √n).
Example 2.1
Solution
First, we need to find ⌊√371⌋ = ⌊19.26⌋ = 19. By the previous Proposition (2.9), if 371 is composite
then it must have a factor less than or equal to 19.
Clearly 2, 3, 4, and 5 are not factors of 371.
What about 6?
Since 6 is even, so it will not go into 371. Let us try the next integer, 7:
371 = 7 × 53.
T ESTI N G N U M B E R S F O R P R I M A L I T Y ( 5 4 – 6 3 ) 59
In the last section we discussed prime numbers, but how do we test for primality?
The previous Proposition (2.9) also says that if there is no divisor d of n such that
1 < d ≤ ⌊√n⌋ then n is prime. (Contrapositive of Proposition (2.9).)
For example, consider the number n = 983.
We use Proposition (2.9) to test if 983 is prime or not.
Why?
Because 983 is either composite or prime. If 983 is composite it must have a factor which is
≤ ⌊√983⌋ = ⌊31.353⌋ = 31.
So for testing whether 983 is prime we need to see if any of the numbers 2, 3, 4, ⋯, 31 are
factors of 983. Verify in your own time that these numbers are not factors of 983. Hence
983 is prime.
Even with a calculator, this is a pretty tedious task (checking 2, 3, 4, ⋯, 31 are divisors of
983) for a small number such as 983.
Yes. The next corollary states that in order to test the integer n for compositeness, we only
need to check whether the primes up to ⌊√n⌋ are factors of n.
Corollary (2.10). If n > 1 is composite then it has a prime divisor p such that p ≤ ⌊√n⌋.
Proof.
By the previous Proposition (2.9):
If n is composite then it has a divisor d such that 1 < d ≤ ⌊√n⌋.
We have that n has a divisor d such that 1 < d ≤ ⌊√n⌋. By the Fundamental Theorem of
Arithmetic (2.5):
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
60 2 P R IM ES A ND FAC TO R I Z AT I O N
Well for testing whether 983 is prime or composite we only need to see if the primes less
than or equal to ⌊√983⌋ = 31 go into 983. The primes up to 31 are
There are 11 primes ≤ 31, and we only need to test if any of these are divisors of 983. By the
earlier Proposition (2.9) we had to check whether all the numbers between 2 and 31, that
is 2, 3, 4, 5, 6, 7, ⋯, 30, and 31, are divisors of 983.
Corollary (2.10) implies that to test a given integer n > 1 for primality we only have to
divide by the prime numbers between 2 and ⌊√n⌋.
The last Corollary (2.10) is a lot more useful to us than Proposition (2.9) because we can
test for primality with fewer divisors.
Example 2.2
Test if 1001 is prime. If 1001 is composite, write down its prime decomposition.
Solution
We first find ⌊√1001⌋ = ⌊31.63⌋ = 31. We need to check whether the following primes go into 1001:
Since the primes 2, 3, and 5 are not factors of 1001 these cannot be factors of 143 because 143 1001.
The next prime, 7, is also not a factor of 143, but 11 is:
11 × 13 = 143.
Example 2.3
Solution
We first find ⌊√1607⌋ = ⌊40.087⌋ = 40. The list of primes below 40 are
Check for yourself that none of these primes in the list are a factor of 1607.
Therefore, 1607 is prime.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T ESTI N G N U M B E R S F O R P R I M A L I T Y ( 5 4 – 6 3 ) 61
Ancient Greeks were interested in finding the quantity of primes below a given number. For
example, there are 25 primes below 100 and 78 498 below a million. Eratosthenes developed
a method to find the primes below a given number which has come to be known as the Sieve
of Eratosthenes.
Table 2.1, below, shows the Sieve of Eratosthenes for positive integers less than or equal
to 100.
Table 2.1
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
62 2 P R IM ES A ND FAC TO R I Z AT I O N
First, we write down all the integers between 2 and 100. Since 2 is prime, we circle all the
multiples of 2 or the even numbers apart from 2 itself. The first of the remaining integers
is 3, so it must be prime. Now we circle out all the multiples of 3 apart from 3 itself. We
continue this process for 5, 7, 11, 13, . . . The integers which do not fall through this sieve
are the prime numbers:
Hence the primes below 100 are
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
47, 53, 59, 61, 67, 71, 73, 79, 83, 89, and 97.
We use the following notation to count the number of primes:
Let x be any positive integer. Then 𝜋 (x) is the number of primes below or equal to x.
This might be a confusing use of the symbol 𝜋, but most of the literature on this topic tends
to use 𝜋 (x) to represent the number of primes less than or equal to x because the great
mathematician Gauss used this notation.
It is important that you don’t read this 𝜋 (x) as ‘𝜋 times x’.
For example,
𝜋 (100) = 25, 𝜋 (200) = 46, 𝜋 (1000) = 168, and 𝜋 (1 000 000) = 78 498.
Infinitely many.
The following proof which was given by the Greek mathematician Euclid (300 BC) in his
13-volume Elements is one of the most beautiful.
By contradiction.
Proof.
Suppose we have a finite number of primes, these being
2, 3, 5, 7, 11, ⋯ , Q (∗)
N = (2 × 3 × 5 × 7 × 11 × ⋯ × Q) + 1. (†)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T ESTI N G N U M B E R S F O R P R I M A L I T Y ( 5 4 – 6 3 ) 63
[This N is the product of the numbers in the list (∗) and then add 1. This N is often called
Euclid’s number.] This number N is either prime or composite.
If N is prime, then we are done because we have found a larger prime than Q, which
means that Q could not have been the largest prime.
If N is composite, then by the Fundamental Theorem of Arithmetic it must have a prime
factor, say P. This prime factor P cannot be one of the primes in the list (∗).
Why not?
P [N − (2 × 3 × ⋯ × P × ⋯ × Q)] implies P 1.
[Because by (†) we have N − (2 × 3 × ⋯ × P × ⋯ × Q) = 1] .
This P 1 is impossible because P is prime. We have found a prime which is not in the
list (∗).
Hence there cannot be a finite number of primes.
Summary
If n > 1 is composite then it has a prime divisor p such that p ≤ ⌊√n⌋ where ⌊ ⌋ is the floor function.
EXERCISES 2.2
64 2 P R IM ES A ND FAC TO R I Z AT I O N
.........................................................................................................
This section is split into two parts. In the first part we examine some unsolved problems
about primes, as there are many unanswered questions in number theory. For a more com-
prehensive list of unsolved problems in number theory, see the book by Richard Guy—
Unsolved Problems in Number Theory.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PR O P ERT I E S O F P R I M E N U M B E R S ( 6 4 – 7 6 ) 65
A conjecture is a mathematical statement that has not been proven. Generally, for a con-
jecture our intuition tells us that the statement is true, but we cannot find a proof.
1. Twin prime conjecture (de Polignac, 1846)
Primes like 11 and 13 are examples of twin primes.
Definition (2.12). Twin primes are numbers p and p + 2 where both p and p + 2 are prime.
No one has come up with a proof of this result, although most do believe it is true. The
largest known twin primes so far are
2996863034895 ⋅ 21290000 ± 1.
Lately this difference between primes p and q has been reduced to 246, that is there are
infinitely many pairs of primes p and q such that
q − p < 246.
Of course, the pair of primes p and q which are two apart also lie in this set:
q − p = 2.
However, we don’t know whether this pair p and q, which are two apart, are an infinite
set or a finite set. An interesting article on this can be found on the internet.3
1
In the Annals of Mathematics published by Princeton University and the Institute for Advanced
Study.
2
Closing the Gap by Vicky Neal.
3
https://www.maa.org/sites/default/files/pdf/upload_library/2/Ellenberg-Math%20Hor-
2014.pdf.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
66 2 P R IM ES A ND FAC TO R I Z AT I O N
Every odd integer greater than 5 can be written as a sum p + 2q, where p and q are
both primes.
For example,
Again, this result has not been proven. Mathematicians have been trying to prove this re-
sult for over 270 years. Computers have verified this result for all the even integers up to
4 × 1018 .
There also exists another Goldbach conjecture known as ‘Goldbach’s odd conjecture’,
which claims:
Every odd integer greater than 5 can be written as a sum of three primes.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PR O P ERT I E S O F P R I M E N U M B E R S ( 6 4 – 7 6 ) 67
In 1729, Goldbach began a correspondence with Euler which lasted for 35 years.4 In one
such correspondence in 1742 he made his famous conjecture.
4. Landau’s conjecture (1912)
Landau gave the following conjecture in 1912.
There are infinitely many primes of the form n2 + 1.
22 + 1 = 5, 42 + 1 = 17, 62 + 1 = 37, ⋯ .
If we tweak the n2 + 1 to n2 − 1, we find there is only one prime, 3, which is of this form;
22 − 1 = 3.
Edmund Landau (1877–1938) wrote a 372-page book called Differential and Integral Cal-
culus without a single illustration in the whole book. He proved the fundamental trigono-
metric identity
cos2 (𝜃) + sin2 (𝜃) = 1
with no reference to right-angled triangles. It was proven using the power series for the sine
and cosine functions. Landau defined 𝜋/2 as the smallest positive solution to cos (x) = 0.
There is no mention of the numerical value of 𝜋/2 or 𝜋, nor its relation to the circle.
All four of these problems have remained unproven for hundreds of years.
68 2 P R IM ES A ND FAC TO R I Z AT I O N
Table 2.2
Note that the proportion of primes below 100 is 25% and the proportion of primes below
1000 is 16.8%. The proportion is getting smaller for larger N, as you can observe from the
last column of the above table. For example, there are only two primes between 10100 and
10100 + 1000, but there are 168 between 1 and 1000.
The primes are thinning out for larger and larger values of N.
No, because we have already proved that there are infinitely many primes. Figure 2.8 below
shows the graph of the prime counting function 𝜋 (x) against x:
78498
63951
49098
π(x)
33860
17984
x
200000 400000 600000 800000 1000000
Figure 2.8
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PR O P ERT I E S O F P R I M E N U M B E R S ( 6 4 – 7 6 ) 69
As the slope of the curve is getting smaller for larger N, so this suggests that the primes
are thinning out. So for large numbers we expect to see large gaps between consecutive
primes, which also implies that we should have a large number of consecutive composite
integers.
As we’ve already seen, there is no distribution of the primes which would allow us to tell
where the next prime is located. The twin prime conjecture has shown us that there are
situations where we only have one composite number between two primes. The difference
between two successive prime numbers is called the prime gap; Table 2.3 below gives the
first 12 primes and the corresponding prime gap:
Table 2.3
2 3 5 7 11 13 17 19 23 29 31 37
Gap 1 2 2 4 2 4 2 4 6 2 6
Also 3, 5, and 7 are the only three primes where there is a gap of two between each prime.
You are asked to show this in Exercises 2.3, question 3 (ii).
If we subtract one from the prime gap, then we get the number of consecutive composite
integers between the two primes. We can see that between 23 and 29 there are 6 − 1 = 5
composite integers: 24, 25, 26, 27, and 28.
Actually, we can prove that for any n we can find n consecutive composite integers.
Proposition (2.13). For any positive integer n there exists a consecutive sequence of n com-
posite integers.
This means that between some pairs of successive primes on the number line there will be
n composite integers next to each other.
Proof.
To prove this, we need to find consecutive composite integers, and for this we use the fac-
torial function n!. Recall that n! = 1 × 2 × 3 × 4 × ⋯ × (n − 1) × n.
Consider the list of consecutive integers:
70 2 P R IM ES A ND FAC TO R I Z AT I O N
Consider the first number in this list, I1 = (n + 1)! + 2. We know that 2 is a factor of this
number.
How?
It means that we can choose any positive integer n, 5 for example, and somewhere on the
real number line we will find five composite numbers sat next to each other.
In the case of 5, we find that five composite numbers 24, 25, 26, 27, and 28 sit between the
prime numbers 23 and 29. Another set of five consecutive composite integers lies between
the primes 31 and 37.
This works for all n, no matter how large, so if we choose n to be one million, then some-
where on the number line we will find one million composite integers sat side by side.
The numbers in the list (∗ ) in the proof of Proposition (2.13) can be used to generate n
consecutive composite numbers. For example, if we choose n = 6 then the following six
integers are consecutive composite integers:
Hence 5042, 5043, 5044, 5045, 5046, and 5047 are six composite consecutive integers.
The formula given in the proof of Proposition (2.13) produces a list of at least n consecutive
composite numbers. (It does not give us the first n consecutive composite integers). The
first seven consecutive composite integers are 90, 91, 92, 93, 94, 95, and 96 and we found
these by examining the Sieve of Eratosthenes as described in the last section.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PR O P ERT I E S O F P R I M E N U M B E R S ( 6 4 – 7 6 ) 71
As discussed in the previous subsection, there is no single formula or algorithm which gives
all or some of the primes.
However, can we find a sequence of numbers which picks up all or some of the primes?
4n, 4n + 1, 4n + 2, or 4n + 3.
4n, 4n + 1, 4n + 2, or 4n + 3.
Proof.
Let a be any integer and b = 4, then applying the Division Algorithm with q = n we have
a = 4n + r, 0 ≤ r < 4.
The remainder r can only take values of 0, 1, 2, or 3 because 0 ≤ r < 4. Substituting these
values of r into a = 4n + r gives
a = 4n, 4n + 1, 4n + 2, or 4n + 3.
Why not?
Because these are even numbers so are divisible by 2, and the only even prime is 2.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
72 2 P R IM ES A ND FAC TO R I Z AT I O N
Yes. These numbers 4n + 1 or 4n + 3 cover all the odd numbers. Therefore, all the odd
primes (that is all the primes other than 2) must be captured by either of these numbers,
4n + 1 or 4n + 3.
Next, we prove there are infinitely many primes of the form 4n + 3. For example,
Lemma (2.15). The product of two or more integers of the form 4n + 1 can be written in
the same form, 4n + 1.
Proof.
It is enough to prove this result for two arbitrary integers a and b of the form 4 (integer) + 1.
Let a = 4n1 + 1 and b = 4n2 + 1, then
By contradiction.
Proof.
Suppose there are a finite number of primes of the form 4n + 3. Let these be
p1 , p2 , p3 , ⋯ , P (†)
N = 4 (p1 × p2 × p3 × ⋯ × P) − 1. (∗)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PR O P ERT I E S O F P R I M E N U M B E R S ( 6 4 – 7 6 ) 73
We can rewrite N as
N = 4 (p1 × p2 × p3 × ⋯ × P) − 1
= 4 ([p1 × p2 × p3 × ⋯ × P] − 1) + 3.
Note that N is an odd number and of the form 4n + 3. Either N is composite or prime.
If N is prime then we are done, because we have a larger prime of the form 4n + 3 which
is greater than P.
If N is composite then it has a prime factor of the form 4n + 3.
Why?
N is odd and all odd numbers have the form 4n + 1 or 4n + 3. If all the factors of N were of
the form 4n + 1, then by the previous Lemma (2.15):
Product of two or more integers of the form 4n + 1 is of the same form, 4n + 1.
N would also be of this form 4n + 1, but it is not. Hence N must have at least one prime
factor of the form 4n + 3. Call this prime factor Q.
However, this prime factor Q of N cannot be one of the numbers in the list (†).
Why not?
Q [N − 4 (p1 × p2 × ⋯ × P)] ⇒
⏟ Q (−1) because N − 4 (p1 × ⋯ × P) = −1.
by (∗)
There are also infinitely many primes of the form 4n + 1, but this is much more difficult
to prove without Dirichlet’s Theorem (2.17), which is given next. You are asked to prove
this in Exercises 2.3, question 1 (a).
Dirichlet proved the powerful result that the number of primes in an arithmetic progression
is infinite.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
74 2 P R IM ES A ND FAC TO R I Z AT I O N
In 1855 when Gauss, one of the greatest mathematicians of all time, passed away, Dirichlet
took up his chair in Göttingen. He stayed there until his death in 1859.
Dirichlet was the first to give the formal definition of a mathematical function. In 1837
Dirichlet proved that there are infinitely many primes in an arithmetic progression. With
this he became one of the founders of ‘analytic number theory’, a branch of number theory
which uses mathematical analysis to prove and solve problems in this field. Actually, ana-
lytic number theory is a very peculiar combination because number theory is discrete and
analysis is continuous: William Dunham called this combination onion milkshake.5
Next, we state the powerful result: Dirichlet’s Theorem about primes in an arithmetic
progression.
Consider a sequence of numbers 1, 8, 15, 22, 29, . . . where each term is seven more than
the previous term, then this sequence is an example of an arithmetic progression.
We can write a general arithmetic progression as follows:
a, a + b, a + 2b, a + 3b, ⋯
5
Euler: The Master of Us All by William Dunham.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PR O P ERT I E S O F P R I M E N U M B E R S ( 6 4 – 7 6 ) 75
An arithmetic progression starts at some number, a say, and then proceeds with jumps
of equal size, b. For example, in the above case 1, 8, 15, 22, 29, . . . can be written as
1, 1 + 7, 1 + 2 (7) , 1 + 3 (7) , ⋯ .
Dirichlet’s Theorem (2.17). Let a and b be relatively prime positive integers, then the arith-
metic progression
a, a + b, a + 2b, a + 3b, ⋯
contains infinitely many primes.
Proof.
Omitted. (This is a tough proof and requires analysis. You can find this in most books on
analytic number theory.6 )
Let a = 2 and b = 3, then there are infinitely many primes in the list:
Note that Dirichlet’s Theorem does not claim that the arithmetic progression:
a, a + b, a + 2b, a + 3b, ⋯
consists solely of primes. In the above example, 8 and 14 are clearly not prime.
Example 2.4
Show that there are infinitely many primes that end with 999.
Solution
Let a = 999, b = 1000 so gcd (999, 1000) = 1. We can apply Dirichlet’s Theorem (2.17). We have:
Dirichlet’s Theorem claims that there are infinitely many primes of this form (†).
Not all these numbers are prime, for example 999 is composite because 9 999.
76 2 P R IM ES A ND FAC TO R I Z AT I O N
The converse of result (a) also holds: if prime p is of the form 4n + 1 then it can be written
as the sum of two squares. Moreover, this representation is unique. We prove this amazing
result in Chapter 8.
No. However, there are some simple formulae which generate some primes. For example,
the following quadratic
f (n) = n2 + n + 41
f (40) = 402 + 40 + 41
= 40 (40 + 1) + 41 = 41 (40 + 1) = 412 .
When n = 41 we have
f (41) = 412 + 41 + 41
= 41 (41 + 1 + 1) = 41 (43) .
Hence F5 is a composite number. So far there have been no other Fermat numbers,
n
Fn = 22 + 1, which are prime.
Summary
There are still many problems in number theory which remain unresolved, for example Goldbach’s
conjecture and the twin prime conjecture.
There are infinitely many primes, but there is no pattern apart from them thinning out for larger
and larger values.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 77
EXERCISES 2.3
(Brief solutions at end of book. Full (b) Prove that there are infinitely many
solutions available at <http://www.oup.co. primes of the form 3n + 2.
uk/companion/NumberTheory>.)
(c) Explain why there are no primes of
1. (a) Prove there are infinitely many the form 3n + 3.
primes of the form 4n + 1.
3. (i) Prove that the product of three
(b) Provide another proof that there are consecutive odd numbers is divisible
infinitely many primes of the form by 3.
4n + 3.
(ii) Prove that p = 3 is the only prime
(c) Let p prime such that p > 3. Prove such that p, p + 2, and p + 4 are all
that p is of the form 6n + 1 or prime.
6n + 5.
4. Prove the following important results:
Part (c) means that every prime > 3 can
(a) If a prime p is the sum of two squares
be written as 6n + 1 or 6n + 5.
then p is of the form 4n + 1.
2. (a) Prove that there are infinitely many
(b) A prime of the form 4n + 3 cannot be
primes of the form 3n + 1.
written as a sum of two squares.
.........................................................................................................
Say we want to find the least common multiple of 8 and 10, then we list the multiples of
each:
Multiples of 8 are 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, . . .
Multiples of 10 are 10, 20, 30, 40, 50, 60, 70, 80, 90, . . .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
78 2 P R IM ES A ND FAC TO R I Z AT I O N
40 and 80.
The least of these is 40, so we say the least common multiple or LCM of 8 and 10 is 40.
The least common multiple—LCM of two non-zero integers a and b is the smallest
positive multiple amongst the common multiples of a and b.
Another definition of the LCM of non-zero integers a and b is the least positive integer
which is divisible by both integers a and b.
The LCM of a and b is denoted by [a, b].
Example 2.5
Solution
Listing the multiples of 12, we have
12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, ⋯ .
Yes. Consider non-zero integers a and b, then the product a × b is a common multiple of a
and b. This implies that the LCM of two non-zero integers always exists.
Next we give the formal definition of the LCM.
Definition (2.18). Let m be the LCM of non-zero integers a and b, that is [a, b] = m.
Then m satisfies
(i) both a m and b m [common multiple]
(ii) if both a n and b n then m ≤ n [least multiple].
If we make the lists of multiples of 42 and 44 and then find the smallest common multiple
of these numbers, we get [42, 44] = 924. This is a rather laborious exercise.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 79
Yes. We first find the prime decomposition (the atoms which make up these numbers) of
each of these integers:
42 = 2 × 3 × 7 and 44 = 22 × 11.
So the LCM of 42 and 44 must contain the multiples of these primes 2, 3, 7, and 11. Since
we have 22 in the prime decomposition of 44, so the common multiple must have a 22 .
Therefore, we have
This approach is much easier than listing multiples and then trying to find the smallest
common multiple. We can express this method as follows.
max(e2 , f2 )
[a, b] = p1 max(e1 , f1 ) × p2 × ⋯ × pk max(ek , fk ) .
We don’t. If there is a prime pj present in a but not in b then we write p0j = 1 in the de-
composition of b. (This is not the prime decomposition we discussed when proving the
Fundamental Theorem of Arithmetic, because primes are greater than 1.)
Proof.
See Exercises 2.4, question 16.
Example 2.6
57 = 3 × 19 and 60 = 22 × 3 × 5. (continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
80 2 P R IM ES A ND FAC TO R I Z AT I O N
(ii) We use the result of (i) to determine whether Alice or Bob has the better record.
Why?
Because we can express their hits as a proportion of a common multiple. For economic rea-
sons we write the number of hits out of the LCM.
How many times does 57 go into 1140?
43 43 × 20 860
20, so Alice hits the bullseye = = , or 860 times out of 1140.
57 57 × 20 1140
How many times does 60 go into 1140?
46 46 × 19 874
19, so Bob hits the bullseye = = , or 874 times out of 1140.
60 60 × 19 1140
We conclude that Bob’s record is better, because out of 1140 attempts he has hit the bullseye
874 times compared to Alice’s 860 times.
(iii) From part (i) we have [57, 60] = 1140, therefore
1 1 20 × 1 19 × 1
+ =( )+( )
57 60 20 × 57 19 × 60
20 19 39 13
= + = = .
1140 1140 1140 380
You may argue that in the above example for part (ii) you would prefer to compare the
decimal forms of 43/57 and 46/60. However, this involves division and the above relies on
multiplication, which is an easier arithmetic operation.
If two integers are relatively prime then what is their LCM equal to?
[5, 9] = 45
[100, 101] = 10 100
[333, 1000] = 333 000.
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 81
Proof.
Clearly the product a × b is a common multiple of both integers a and b. We need to show
that a × b is the least multiple of both these integers.
Suppose the LCM of a and b is m, that is [a, b] = m, where m < a × b.
By the definition of the LCM we have
a m and b m.
a × n = m.
b (a × n) .
We are given that a and b are relatively prime, so gcd (a, b) = 1. By Euclid’s Lemma (1.13):
If x (y × z) with gcd (x, y) = 1 then x z.
Applying this to b (a × n) with gcd (a, b) = 1 gives b n. From this b n, we have n ≥ b.
This is a contradiction, because from above we have m < a × b. However, now with n ≥ b
we have m = a × n ≥ a × b.
Hence our supposition that [a, b] = m where m < a × b is wrong, so
[a, b] = a × b.
Determine [5, 1 000 004]. Since 5 and 1 000 004 are relatively prime, so by the previous
result we have
[5, 1 000 004] = 5 × 1 000 004 = 5 000 020.
In Exercises 2.4, question 12 we show that the LCM of two non-zero integers is unique.
How do we find the greatest common divisor, gcd, of two positive integers?
We could use the Euclidean Algorithm which was described in Section 1.3 in the previous
chapter. Another approach is the following:
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
82 2 P R IM ES A ND FAC TO R I Z AT I O N
Proof.
See Exercises 2.4, question 17.
Generally, it is easier to use the Euclidean Algorithm to find the gcd of two given integers
over the prime decomposition method of Proposition (2.21). This is because finding the
prime decomposition of a given integer is a difficult and time-consuming problem.
Example 2.7
Determine gcd (5291, 3108). (We evaluated this in Example 1.17 of the previous chapter.)
Solution
The prime decomposition of each of these numbers is
Hence gcd (5291, 3108) = 37. This method seems easier once we have found the prime decomposi-
tion of each of the numbers.
Next we show the connection between the gcd and the LCM. Consider the following
examples:
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 83
In general, we have
We can use this result to check if we have evaluated the gcd and LCM of two given numbers
correctly.
By using the decomposition of a and b and showing that the left-hand side,
gcd (a, b) × [a, b], is equal to the right-hand side, a × b.
Proof.
Let a = p1 e1 × p2 e2 × p3 e3 × ⋯ × pk ek and b = p1 f1 × p2 f2 × p3 f3 × ⋯ × pk fk be the decomposi-
tions of a and b. [There may not be a prime present which is represented by pj 0 = 1.]
to the left-hand side of the given expression, gcd (a, b) × [a, b] = a × b, which yields
If ej = fj then
min (ej , fj ) + max (ej , fj ) = ej + fj .
If ej < fj then
min (ej , fj ) + max (ej , fj ) = ej + fj .
If ej > fj then we still have
84 2 P R IM ES A ND FAC TO R I Z AT I O N
All three cases give the same result for the index of the primes:
Expanding the right-hand side of the given expression gcd (a, b) × [a, b] = a × b into its
primes yields
a × b = (p1 e1 × p2 e2 × ⋯ × pk ek ) × (p1 f1 × p2 f2 × ⋯ × pk fk )
=
⏟ p1 e1 +f1 × p2 e2 +f2 × ⋯ × pk ek +fk . (∗∗)
by the rules of indices
This proposition gives us an amazing result: gcd times LCM equals the product:
Example 2.8
Solution
(i) We have
(ii) Substituting a = 36, b = 54 and gcd (36, 54) = 18 into the previous result,
36 × 54
18 × [36, 54] = 36 × 54 which implies [36, 54] = = 108.
18
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 85
How do we find the least common multiple of 15, 27, and 36?
Proof.
See Exercises 2.4, question 19.
Example 2.9
Solution
Applying the previous proposition with a1 = 15, a2 = 27, and a3 = 36 gives
Hence [15, 27, 36] = 540. The LCM of 15, 27, and 36 is 540.
86 2 P R IM ES A ND FAC TO R I Z AT I O N
However the integers in {2, 3, 4} are not pairwise prime because gcd (2, 4) = 2.
[a1 , a2 , a3 , ⋯ , an ] = a1 × a2 × ⋯ × an .
Proof.
See Exercises 2.4, question 15.
Summary
In this section we have defined the least common multiple (LCM) of two non-zero integers. The
notation for the LCM of a and b is [a, b] and can be determined by
EXERCISES 2.4
(Brief solutions at end of book. Full 4. (i) Determine [20, 265, 530].
solutions available at <http://www.oup.co. 1 1 1
uk/companion/NumberTheory>.) (ii) Find + + by using the
20 265 530
result of (i).
1. Determine the LCM of the following
pairs of integers: 5. (i) Find [3, 4, 28].
(a) [45, 81] (b) [2000, 2015] (ii) Solve the following equation
(c) [1000, 1001] 1 1 1
+ + +x = 1
2. Hotdogs are sold in packages of ten 3 4 28
and buns come in packages of eight. without using a calculator.
What is the least amount of packages
you will need to purchase in order that 6. Find the LCM of the following:
there are no hotdogs or buns left over? (a) [60, 100]
3. Harry scores a mark of 64 out of 85 for (b) [600, 1 000]
mechanics and 69 out of 91 for real (c) [6 000, 10 000]
analysis. By finding the LCM, state
which examination was a better What do you notice about your results?
performance for Harry.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 87
7. Show that [ab, ac] = a × [b, c] where 14. *There are between 500 and 600
a, b, and c are positive integers. soldiers in a battalion. We know when
[Hint: You may find the following they are divided into groups of six,
Proposition (1.11) helpful: eight, and 11 that there are three left
gcd (ab, ac) = a × gcd (b, c) provided over in each case. How many soldiers
a > 0.] are there in the battalion?
8. Let p and q be distinct primes. Show 15. Prove Corollary (2.24).
that [p, q] = p × q. [Hint: You may find the result of
Exercises 1.3, question 15 (ii) useful:
9. Prove that [a, ma] = ma where m and
gcd (a, n1 ) = gcd (a, n2 ) = ⋯ =
a are positive integers.
gcd (a, nk ) = 1 then
10. Let a, b and a, c be relatively prime
positive integers. Prove that gcd (a, n1 × n2 ⋯ × nk ) = 1.]
(c) If [a, b] = n and [b, c] = m then [Hint: You may find the result of
[a, c] = m × n. Exercises 1.3, question 16 useful:
If gcd (x, y) = 1 then
(d) [a + b, c] = [a, c] + [b, c]
(e) [ab, ac] = a2 [b, c] gcd (x + y, xy) = 1.]
.........................................................................................................
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
88 2 P R IM ES A ND FAC TO R I Z AT I O N
Supplementary Problems 2
(Brief solutions at end of book. Full 2.9. Show that the only prime of the form
solutions available at <http://www.oup.co. n3 − 1 is 7 where n is a natural
uk/companion/NumberTheory>.) number.
[Hint:
2.1. Factorize the following integers into
an − 1 = (a − 1) (an−1 + an−2 +
their prime factors:
an−3 + ⋯ + 1).]
(a) 100 (b) 1000 (c) 161
2.10. Show that:
(d) 201 (e) 301
(a) For any real x the following is
2.2. Determine the following:
false: ⌈x⌉ = ⌊x⌋ + 1.
1 1 𝜋
(a) ⌊ ⌋ (b) ⌊− ⌋ (c) ⌈− ⌉ (b) If x is not an integer then the
2 2 4
following is true: ⌈x⌉ = ⌊x⌋ + 1.
𝜋
(d) ⌊− ⌋ (e) ⌊−7.1⌋ + ⌈−7.1⌉ (c) For any real x we have
4
(f) ⌊−7.1⌋ + ⌈7.1⌉ ⌊x + m⌋ = ⌊x⌋ + m where m is an
2.3. Determine integer.
⌊𝜋⌋ ⌊e⌋ (d) For any real x we have
(a) ⌊e⌋ + ⌊𝜋⌋
⌈𝜋⌉ ⌈e⌉ ⌈x + m⌉ = ⌈x⌉ + m where m is an
(b) ⌈e⌉ + ⌈𝜋⌉
⌈𝜋⌉ ⌈e⌉ integer.
(c) ⌈e ⌉ + ⌈𝜋 ⌉
2.11. Test whether the following numbers
2.4. Determine ⌊√⌊x⌋⌋ and ⌊√x⌋ for the
are prime:
following:
(a) 907 (b) 1009 (c) 1331
(a) x = 100
(b) x = 1000 2.12. Demonstrate that 101 and 103 are
(c) x = 2.75 twin primes.
What do you notice about your results? 2.13. Prove that gcd (p + 1, p2 + 1) = 2
where p is an odd prime.
2.5. Plot the graph of ⌊x⌋ + ⌈x⌉.
2.14. Prove that there are infinitely many
2.6. Explain why ⌊x⌋ ≤ x and ⌈x⌉ ≥ x by primes that end in 111.
sketching appropriate graphs. 2.15. Prove that there are infinitely many
2.7. Justify the following by sketching primes of the form 8n + 3.
appropriate graphs: 2.16. Show that p2 + 2p + 1 is composite
(a) x − 1 < ⌊x⌋ ≤ x for all the primes p.
(b) x ≤ ⌈x⌉ < x + 1 2.17. Show that pn (n is a natural number)
2.8. Show that the only prime of the form is odd for primes p ≥ 3.
n2 − 1 is 3 where n is a natural
number.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
L EA ST C O M M O N M U LT I P L E — LC M ( 7 7 – 8 9 ) 89
2.18. Prove that p4 + 4p2 + 5 is composite 2.23. Let x be a real number. Show that
for prime p. ⌊x⌋ + ⌊−x⌋ =
[Hint: Complete the square.] 0 if x is an integer
{
2.19. Let n be a square integer. Show that −1 if x is not an integer
every exponent of the prime 2.24. Provide another proof of Proposition
decomposition of this number is (2.20). [Hint: The result of Exercises
even. 1.3, question 12 (i) may be helpful:
2.20. Prove that n3 + 1 is composite for x z and y z, and gcd (x, y) = 1 then
n ≥ 2. (x × y) z].
2.21. *Prove that the number nm − 1 2.25. *Prove Proposition (2.22) without
is composite for n > 2 and using the prime decompositions of
m ≥ 2. integers.
2.26. Let a and n be positive integers with
2.22. In the following cases find the first
n > 1. Prove that:
positive integer n for which f (n) is
(a) **If an − 1 is prime then a = 2
composite:
and n is prime.
(a) f (n) = 2n2 + 11 (b) If a ≥ 3 then an − 1 is composite.
(b) f (n) = 2n2 + 29 2.27. Let n be a natural number and p be
prime. Show that if p an then p a.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
..............................................................................................................................
Theory of Modular
3 Arithmetic
..............................................................................................................................
Often, we are only interested in a particular property of a large positive number. For exam-
ple, we might be interested in the following questions:
1. What is the last digit of 2127 ?
2. Is 10171 + 1 divisible by 17?
3. What is the remainder when 1! + 2! + 3! + ⋯ + 20! is divided by 20?
To deal with such questions about large numbers we use modular arithmetic, which is
very similar to our normal arithmetic, as you will find later in this section.
In fact, we already use modular arithmetic every day. Simply being able to use a clock
requires us to use modular arithmetic in modulo 12 hours. We don’t say ‘13 o’clock’, we start
again at one o’clock. This is very useful; aside from anything else a 24-hour clock face would
be extremely cluttered.
The same logic applies here; if we are simply investigating some property of an integer
that doesn’t require us to know its precise digits, it is often enough to express it simply as a
multiple of some smaller integer plus any remainder.
Another name for modular arithmetic is the ‘arithmetic of remainders’, because we clas-
sify a number according to the remainder when divided by a fixed number n called modulo
n. The plural of modulo is moduli.
Modular arithmetic converts the infinite number line into a cyclical loop because it is
often an extremely efficient way of analysing large integers (see Figure 3.1 on the next page).
In modular arithmetic, the arithmetic is done in a loop or circle rather than on a number
line.
In a nutshell, modular arithmetic takes the infinite number line and converts it into a
loop and from this loop we can deduce many properties of numbers. For example, we can
use modular arithmetic to answer the following questions:
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
92 3 T HE ORY OF M O D U L A R A R I T H M ET I C
We will show that if the sum of digits of an integer divides into 9 then the integer is divisible
by 9. This is an easy check to see if any number is divisible by 9, and we will cover this in
Example 3.8 at the end of this section.
(The day Britain and France declared war on Germany.) Actually, modular arithmetic can
be used to compute any day of the week in history or in the future.
9
What are the last two digits of 99 ?
You are asked to find these digits in Exercises 3.1, question 30.
We rely on modular arithmetic more than you might think; your bank uses modular arith-
metic to verify that your credit card number is well formed, and the bar code on supermar-
ket products is also verified using modular arithmetic.
The notation 10 ≡ 3 (mod 7) is simply a way of expressing the number 10 in modulo 7, that
is 10 can be expressed as a multiple of 7 (in this case 1 × 7) with a remainder of 3. It is
verbally stated as ‘10 is congruent to 3 modulo 7’. The symbol for ‘congruent to’ is ≡ and
modulo n is normally shortened to (mod n).
Examples of modular arithmetic are:
(a) 10 ≡ 3 (mod 7). Modulo 7 is useful for evaluating days of the week. For example, if
today is Monday then in ten days’ time it will be Thursday because 10 ≡ 3 (mod 7)
tells us that the quantity contains at least one full cycle of seven, that is Monday to
Monday, plus three days.
(b) 25 ≡ 1 (mod 2). Modulo 2 is useful for seeing if the number is odd or even by check-
ing for a remainder of 0 or 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 93
(c) 50 ≡ 2 (mod 24). Modulo 24 can be used to find the time using a 24-hour clock. Sup-
pose it is 9am, then in 50 hours’ time it will be 11am because
50 ≡ 2 (mod 24),
that is an undefined number of cycles from 9am to 9am, plus two hours. We say that
50 is congruent to 2 (mod 24).
Definition (3.1). Let n be a fixed positive integer and a, b be integers. We say ‘a is congruent
to b modulo n’ and it is denoted by
a ≡ b (mod n)
a = (k × n) + b.
94 3 T HE ORY OF M O D U L A R A R I T H M ET I C
If the remainder is zero, that is b = 0 in the above definition, then we say a is divisible by
n or n is a divisor of a denoted n | a. For example:
6 ≡ 0 (mod 3) because 6 = (2 × 3) + 0
540 ≡ 0 (mod 6) because 540 = (90 × 6) + 0
a ≡ 0 (mod n) ⇔ n | a.
Proof.
Applying Definition (3.1):
a ≡ b (mod n) ⇔ a − b = kn,
to a ≡ 0 (mod n) gives
a ≡ 0 (mod n) ⇔ a − 0 = kn ⇔ n | a.
Hence a − 0 = a is a multiple of n or n | a.
We are not interested in dividing by 1 because the remainder will always be zero, that is
for every integer a we have a ≡ 0 (mod 1).
For congruences we consider modulo n ≥ 2.
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 95
Similarly, we have
7, 14, 21, 28, … days after Thursday is a Thursday, so we are interested in the remain-
der of 100 divided by 7, which is 2. Hence in 100 days time it will be Saturday because
100 ≡ 2 (mod 7).
We have a = (n × q) + r ⇔
What about the residues {7, 8, 9, 10, 11, 12, 13} modulo 7?
96 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Example 3.1
Solution
We can illustrate modulo 7 as a circle or clock, as shown in Figure 3.3.
We carry out the arithmetic for modulo 7 on this clock with the addition of integers going clockwise
and the subtraction of integers going anticlockwise:
We can consider integers from 14 onwards: {14, 15, 16, 17, 18, 19, 20}.
We can also consider negative integers which go anticlockwise, as you can observe from Figure 3.3.
Hence a set of negative integers which form a complete set of residues is
If a set of integers covers all the junctions (⋅) around the clock and this set only stops once
at each junction, then the set is said to be a complete system of residues. The formal defi-
nition is:
Definition (3.3). The set {r1 , r2 , r3 , ⋯ , rn−1 , rn } is said to form a complete set of residues
modulo n if every integer is congruent to one and only one rk in the set. This is also called
a complete system of residues modulo n.
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 97
Can we define a unique set of integers which forms a complete system of residues?
Example 3.2
Solution
Example 3.3
Solution
34 ≡ 4 (mod 10) so x = 4.
If in a set of residues {r1 , r2 , r3 , ⋯ , rn−1 , rn } there are two or more residues congruent
to each other modulo n, then this system cannot form a complete system of residues. This
means the set stops at least twice at a particular junction.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
98 3 T HE ORY OF M O D U L A R A R I T H M ET I C
For example, none of the following are a complete system of residues modulo 5:
{10, 15, 20, 25, 30} , {−1, −2, −3, −4, −8} , and {0, 1, 2, 3, 4, 7} .
Why not?
In the first set {10, 15, 20, 25, 30}, all the numbers are congruent to 0 modulo 5. The
stops 1, 2, 3, 4 (mod 5) are missing, so this set is not a complete system.
In the second set, {−1, −2, −3, −4, −8}, the stop 0 (mod 5) is missing, so cannot be a
complete system.
In the third set {0, 1, 2, 3, 4, 7} , we have 7 ≡ 2 (mod 5). This means we have two stops
at junction 2 (mod 5). Remember for a complete system we can only have one stop at each
junction.
a ≡ b (mod n)
Since we have the symbol ⇔ in the statement, we need to prove this both ways: ⇒ and ⇐.
We use Definition (3.1) and the Division Algorithm.
Proof.
(⇒). We assume a ≡ b (mod n). By Definition (3.1):
a ≡ b (mod n) ⇔ a − b = kn.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 99
a − b = kn. (∗)
a = q1 n + r1 , 0 ≤ r1 < n.
b = q2 n + r2 , 0 ≤ r2 < n.
a − b = q1 n + r1 − (q2 n + r2 )
= (q1 − q2 ) n + (r1 − r2 )
=
⏟ kn where k = q1 − q2 .
by (∗)
a = q1 n + r 0≤r<n
b = q2 n + r 0 ≤ r < n.
a − b = q1 n + r − q2 n − r
= (q1 − q2 ) n.
a ≡ b (mod n).
An example of this result is
47 ≡ 37 ≡ 27 ≡ 7 (mod 10).
a ≢ b (mod n).
100 3 T HE ORY OF M O D U L A R A R I T H M ET I C
For example, 47 ≢ 6 (mod 10), because 47 divided by 10 gives remainder 7 and 6 divided
by 10 gives remainder 6. We say 47 is incongruent to 6 modulo 10.
The congruent symbol, ≡, can easily be confused with the equal sign =. This is because they
look alike, but they also have very similar properties.
a ≡ b (mod n) ⇔ a − b = kn.
Proof of (i).
We have a − a = 0 and 0 is a multiple of n because n × 0 = 0 therefore a ≡ a (mod n).
Proof of (ii).
We have a ≡ b (mod n), and this implies there is an integer k such that
a − b = kn [a − b is a multiple of n].
− (a − b) = −kn
b − a = (−k) × n [b − a is a multiple of n] .
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 101
Proof of (iii).
We assume a ≡ b (mod n) and b ≡ c (mod n). By using Definition (3.1) there exist integers
k and m such that
a − b = kn [a − b is a multiple of n]
b − c = mn [b − c is a multiple of n] .
a − b + b − c = kn + mn
a − c = (k + m) n [Simplifying and factorizing] .
From the last line we have a − c is a multiple of n, which implies a ≡ c (mod n).
We also need to establish some results, which involves addition, subtraction, and mul-
tiplication in modular arithmetic. We will leave division (or the multiplicative inverse) in
modular arithmetic for Section 3.3 of this chapter.
The next result concerns the addition and multiplication in modular arithmetic.
(i) 1729 + 4159 ≡ 2 + 1 ≡ 3 (mod 11) and (ii) (1729 × 4159) ≡ (2 × 1) ≡ 2 (mod 11) .
Notice that we did not need to evaluate the sum 1729 + 4159 or the product 1729 × 4159.
See how modular arithmetic subdues these numbers.
x ≡ y (mod n) ⇔ x − y = kn.
Proof of (i).
We are given a ≡ b (mod n) and c ≡ d (mod n). By this Definition (3.1) there exist integers
k and m such that
a − b = kn [a − b is a multiple of n]
c − d = mn [c − d is a multiple of n] .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
102 3 T HE ORY OF M O D U L A R A R I T H M ET I C
a − b + (c − d) = kn + mn
(a + c) − (b + d) = (k + m) n [Rearranging and factorizing] .
a + c ≡ (b + d) (mod n).
Proof of (ii).
Similarly, we have a − b = kn and c − d = mn where k and m are integers. Multiplying the
first a − b = kn by c and multiplying the second c − d = mn by b:
ac − bc = knc
bc − bd = bmn.
Example 3.4
Solution
Since we are given that our starting point is 7am, so we use modulo 24.
What do we need to determine first?
Write 100 modulo 24 in terms of the least non-negative residue:
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 103
Since we start at 7am, adding 7 ≡ 7 (mod 24) and 100 ≡ 4 (mod 24) gives
At the start of this chapter we mentioned that modular arithmetic is used to find properties
of large numbers. Consider the following example.
Example 3.5
Solution
Recall what n! means:
n! = n × (n − 1) × (n − 2) × ⋯ × 3 × 2 × 1.
To find the remainder after dividing by 20 means we have to work with modulo 20.
Adding the first few terms of the given sum, we have:
(mod 20)
≡ 1⏟⎵
+⎵2⎵⏟⎵
+ 6⎵
+⎵⏟
24 +20 (3) (2) + 6 (20) (3) (2) + ⋯ (mod 20)
=33
≡ 33 + ⏟
0 + ⏟
0 + ⏟
0 +⋯+
Multiple of 20 Multiple of 20 Multiple of 20
⏟
0 (mod 20)
Multiple of 20
≡ 33 ≡ 13 (mod 20)
Hence the remainder is 13 after dividing the large sum 1! + 2! + ⋯ 99! + 100! by 20.
Note that modular arithmetic tones down large numbers, as you can observe from
Example 3.5. Next, we look at adding or multiplying the same congruence modulo n to
both sides:
104 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Like the equal sign, adding or multiplying by the same congruence keeps the same congru-
ent relationship.
Proof.
If we apply the previous Proposition (3.6):
If a ≡ b (mod n), c ≡ d (mod n) then
(i) a + c ≡ b + d (mod n) (ii) ac ≡ bd (mod n) ,
with c ≡ c (mod n), then we have both our results:
We did not need to evaluate these large numbers 365100 and 13511 .
(365100 has 730 digits and 13511 has 570 digits.)
a × c ≡ b × d (mod n).
Proof.
We are given a ≡ b (mod n), so the result is true for k = 1. Assume it is true for an arbitrary
k = m, that is am ≡ bm (mod n). Consider the case k = m + 1:
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 105
We can use all these properties of adding, multiplying, and taking powers of congruences
to evaluate remainders of numbers.
In the next example we demonstrate how modular arithmetic is used to find the last digit
of a large number without finding all the digits of the number itself.
Example 3.6
Solution
The calculator will not show the last digit of this number 3101 because the number is too large (it has
49 digits):
3101 = ⏟⎵
3 ×⎵×⎵⏟⎵
3⎵ 3× ⎵
⋯ ×3.
⎵⎵⏟
101 copies
0 (mod 10)
–1 or 9 (mod 10) 1 (mod 10)
Subtract Add
numbers numbers
–2 or 8 (mod 10) 2 (mod 10)
this way. this way.
Modulo 10
Figure 3.5
We want to write the index 101 as a multiple of 2 plus a remainder because from above we have
32 ≡ −1 (mod 10), and this makes the arithmetic easier as we have a −1:
Therefore, the last digit of 3101 is 3, because the remainder after division by 10 is 3.
We will examine the last few digits of various integers in Chapters 4 and 5.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
106 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Example 3.7
Solution
What does the notation 42 | (1370 − 1) mean?
42 is a factor of 1370 − 1. This number 1370 − 1 has 78 digits, which is cumbersome to write down in
decimal format.
How are we going to show 42 divides 1370 − 1?
Using modular arithmetic with modulo 42. Note that:
35
1370 ≡ (132 ) [Because 70 = 2 × 35]
35
≡ (1) [Because 132 = 169 ≡ 1 (mod 42)]
≡ 1 (mod 42).
42 | (1370 − 1).
We did not need to find the actual digits of the number 1370 − 1 in order to show that 42
is a factor of this number.
The next proposition says that the congruence relationship holds in a polynomial which
has integer coefficients—see Introductory Chapter for what is meant by a polynomial.
For example,
5x7 + 3x6 + 2x5 + ⋯ + x2 + 3x + 1
is a polynomial with integer coefficients.
Proof.
See Exercises 3.1, question 31.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 107
Example 3.8
Show that if the sum of digits of an integer divides into 9 then the integer is divisible by 9.
Solution
This is a very useful result in determining whether a number is divisible by 9 or not. For example, test
whether 984 567 is divisible by 9:
The sum of the digits is 9 + 8 + 4 + 5 + 6 + 7 = 39 and 9 does not divide into 39, therefore 984 567
is not divisible by 9.
Test 111 111 111 for divisibility by 9:
Similarly adding the digits of 111 111 111 gives
Proof.
Let the integer be N = an an−1 an−2 ⋯ a2 a1 a0 . The sum S of the digits is given by
How do we show that this results in 9 divides into the given integer N?
We show that N ≡ 0 (mod 9).
It means that the unit’s digit is a0 , 10’s digit is a1 , 100’s digit is a2 , and so on:
Table 3.1
n−1 2 1 0
10n 10 ⋯ 10 = 100 10 = 10 10 = 1
an an−1 ⋯ a2 a1 a0
N = an an−1 an−2 ⋯ a2 a1 a0
= (an × 10n ) + (an−1 × 10n−1 ) + (an−2 × 10n−2 ) + ⋯ + (a2 × 102 ) + (a1 × 10)
+ (a0 × 1).
108 3 T HE ORY OF M O D U L A R A R I T H M ET I C
N ≡ an an−1 an−2 ⋯ a2 a1 a0
≡ (an × 10n ) + (an−1 × 10n−1 ) + ⋯ + (a2 × 102 ) + (a1 × 10) + (a0 × 1) (mod 9)
≡ (an × 1) + (an−1 × 1) + ⋯ + (a2 × 1) + (a1 × 1) + (a0 × 1) [By above results]
≡ an + an−1 + an−2 + ⋯ + a2 + a1 + a0
⏟ S ≡ 0 (mod 9)
≡ [By (†)] .
By (∗)
In the last calculation we had N ≡ S (mod 9) which implies N − S = 9k, which we can re-
arrange as N − 9k = S. This implies that if 9 | N then 9 | S. We can re-state the above result
of Example 3.8 as:
Summary
Modular arithmetic is used to deduce certain properties of large numbers.
EXERCISES 3.1
I N TR O D U CT I O N TO C O N G RU E N C E S ( 9 1 – 1 1 0 ) 109
4. Determine x where x is the least 10. *Find the last two digits of 20142014 .
non-negative residue modulo n in the (This number has 6655 digits.)
following:
11. (a) Show that if a is an even number
(a) 100 ≡ x (mod 12) and n is a natural number then an is
(b) 666 ≡ x (mod 11) also even.
(c) −5 ≡ x (mod 15)
(b) Show that if a is an odd number
(d) 1000 ≡ x (mod 1001) and n is a natural number then an is
(e) −25 ≡ x (mod 7) also odd.
(f) −100 ≡ x (mod 24)
12. (a) Show that a square number a2
5. Find x where x is the least divided by 3 gives only remainders 0
non-negative residue modulo n of the or 1.
following:
(b) Show that a square number a2
(a) 2789 + 2788 ≡ x (mod 2787) divided by 4 gives only remainders 0
(b) 2789 × 2788 ≡ x (mod 2787) or 1.
(c) 5201 + 5211 ≡ x (mod 5200)
(d) 5201 × 5211 ≡ x (mod 5200) 13. Let p be prime of the form
p ≡ 3 (mod 4). Show that p cannot be
(e) 5198 + 5188 ≡ x (mod 5200)
written as the sum of two squares.
(f) 5198 × 5180 ≡ x (mod 5200)
[Hint: Use the result of question
6. Find the least non-negative residue of 12 (b).]
1729 (mod 5) , 1729 (mod 11), and
14. Let n be a natural number. Prove that
1729 (mod 1001).
6n ≡ 6 (mod 10).
7. Determine the last two digits of the
What conclusion can you draw about the
following by using modular last digit of powers of 6?
arithmetic:
15. Show that 2m ≢ 0 (mod 10) where m is
(a) 4 352 709 × 4 678 829 a natural number.
(b) 43527835
What does this mean in relation to digits of
8. Determine whether the following are 2m ?
true or false: [Hint: Write m = 4q + r 0 ≤ r < 4.]
(a) 12 ≡ 232 (mod 5) 16. Prove that the last digit of a square
(b) 15 ≢ 5 (mod 10) number can only be 0, 1, 4, 5, 6, or 9.
(c) 12 ≡ −1 (mod 11)
17. Let a be any integer. Show that the last
(d) 365 ≢ 1 (mod 7)
(e) −65 ≡ −29 (mod 12) digit of a3 can be any digit from 0 to 9.
(f) −43 ≢ −46 (mod 2) 18. *Disprove the following statements:
9. Determine the last digit of the (a) a2 ≡ b2 (mod n) ⇒ a ≡ b (mod n)
following numbers:
(b) a × b ≡ 0 (mod n) ⇒
(a) 3100 (b) 9100 a ≡ 0 or b ≡ 0 (mod n)
(c) 2100 (d) 4100
(c) ac ≡ bc (mod n) ⇒ a ≡ b (mod n).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
110 3 T HE ORY OF M O D U L A R A R I T H M ET I C
19. Find the remainders in the following where pj ’s are distinct primes and
cases: a ≡ b (mod n) then a ≡ b (mod pj ) for
(a) 11567 is divided by 61 j = 1, 2, ⋯ , m.
(b) 11567 is divided by 43 25. Prove that a3 − a ≡ 0 (mod 3).
5
20. Show that F5 = 22 + 1 (Fermat 26. Show that 3 divides 4n − 1 where n is a
number with n = 5) is divisible natural number.
by 641.
27. Show that a natural number is divisible
21. Determine the last digit of by 3 if and only if the sum of the digits
1! + 2! + 3! + 4! + ⋯ + 1000!. is divisible by 3.
22. Determine the last digit of the 28. Show that
following numbers: (i) x7 ≡ x (mod 7)
(a) 19611961 (ii) x7 ≡ x (mod 6)
(b) 10231022 (iii) x7 ≡ x (mod 42)
(c) 20192019 29. *Prove the following by induction:
23. *Prove that at least one of k 22n+1 ≡ 9n2 − 3n + 2 (mod 54) where n
consecutive integers is divisible by k. is a natural number.
9
24. (a) Prove that if m | n and 30. *Show that the last two digits of 99 are
a ≡ b (mod n) then a ≡ b (mod m). 8 and 9.
.........................................................................................................
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
CO N G RU E N T PR O P ERT I E S O F M U LT I P L I C AT I O N ( 1 1 1 – 1 1 7 ) 111
ac = bc implies that a = b.
There are cases where we can divide through by a common factor. For example,
Why does this cancellation work in some cases but not all?
The next proposition gives the criteria governing when we can cancel out common factors.
Cancelling out common factors makes the arithmetic simpler.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
112 3 T HE ORY OF M O D U L A R A R I T H M ET I C
n
Proposition (3.10). If ac ≡ bc (mod n) then a ≡ b (mod ) where g = gcd (c, n).
g
Proof.
Let g = gcd (c, n) so there exist integers x and y such that
gx = c and gy = n. (∗)
n n
We are required to prove that divides a − b, or in notation form | (a − b).
g g
Why?
n
Because our aim is to show a ≡ b (mod ).
g
n
From (∗) we have y = , which means it is enough to prove that y | (a − b) .
g
How?
CO N G RU E N T PR O P ERT I E S O F M U LT I P L I C AT I O N ( 1 1 1 – 1 1 7 ) 113
To y | [(a − b) × x] with gcd (y, x) = 1 gives y | (a − b). We have our result because
n n
a ≡ b (mod y) implies a ≡ b (mod ) [Because y = ]
g g
n
If ac ≡ bc (mod n) then a ≡ b (mod ) where g = gcd (c, n).
g
4
2 × 3 ≡ 2 × 7 (mod 4) implies 3 ≡ 7 (mod ) ≡ 7 (mod 2) .
2
6
3 × 15 ≡ 5 × 15 (mod 6) implies 3 ≡⏟ 5 (mod ) ≡ 5 (mod 2).
Because gcd (15, 6)=3 3
We can also use this Proposition (3.10) to help us solve linear congruences.
Example 3.9
[This is an example of a linear congruence which we will discuss in the next section.]
Solution
We can rewrite the given congruence as 15x ≡ 15 × 3 (mod 10).
The greatest common divisor of 15 and 10 is
n
ac ≡ bc (mod n) implies a ≡ b (mod ) where g = gcd (c, n),
g
10
x ≡ 3 (mod ) ≡ 3 (mod 2) ≡ 1 (mod 2).
5
The solution x ≡ 1 (mod 2) implies that x is an odd integer because the integers x satisfy x − 1 = 2t
(because x − 1 is a multiple of 2) where t is an integer or
x = 2t + 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
114 3 T HE ORY OF M O D U L A R A R I T H M ET I C
By substituting various integers for t we have the following odd values for x:
x = 1, 3, 5, 7, ⋯ , −1, −3, ⋯ is a solution to 15x ≡ 45 (mod 10).
Let us consider the special case where gcd (c, n) = 1, that is integers c and n have no factor
in common apart from 1—they are relatively prime.
Cancellation Law (3.11). If ac ≡ bc (mod n) and gcd (c, n) = 1 then a ≡ b (mod n).
Proof.
Applying the previous Proposition (3.10) with g = gcd (c, n) = 1 gives
n
ac ≡ bc (mod n) implies a ≡ b (mod ) ≡ b (mod n).
1
An example is
Remember this solution x ≡ 3 (mod 11) implies x is 3 more than a multiple of 11, that is
x = 3 + 11t where t is any integer.
Next, we consider the Cancellation Law for modulo prime numbers.
a ≡ b (mod p).
Proof.
We are given the prime p does not divide c so gcd ( p, c) = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
CO N G RU E N T PR O P ERT I E S O F M U LT I P L I C AT I O N ( 1 1 1 – 1 1 7 ) 115
Why?
a × b = 0 implies a = 0 or b = 0.
There are cases where a × b ≡ 0 (mod n) implies b ≡ 0 (mod n). Examples are
Why does this a × b ≡ 0 (mod n) imply b ≡ 0 (mod n) work in these cases but not in the general case?
Because in each of these cases the integers a and n are relatively prime. This means it only
works when gcd (a, n) = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
116 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Proof.
We have a × b ≡ 0 (mod n) implies a × b ≡ a × 0 (mod n). Applying Cancellation Law (3.11):
If x × y ≡ x × z (mod n) and g = gcd (x, n) = 1 then y ≡ z (mod n).
To a × b ≡ a × 0 (mod n) with gcd (a, n) = 1, we have b ≡ 0 (mod n) which is our required
result.
Ideally can we find a general analogous result to the one in basic algebra:
a × b = 0 implies a = 0 or b = 0?
Next is the general result which connects multiplication of two integers which is congruent
to zero modulo a prime.
Both these results are important because they are used to solve linear and quadratic con-
gruences later in the book.
Proof of (a).
We are given a × b ≡ 0 (mod p) , therefore p | (a × b). By Proposition (2.2):
If p is prime and p | (a × b) then p | a or p | b.
We have p | a or p | b, which implies a ≡ 0 (mod p) or b ≡ 0 (mod p).
This completes our proof.
Proof of (b).
See Exercises 3.2, question 7.
Note that Proposition (3.14) (a) is only true if we have a prime modulo:
a2 ≡ b2 (mod p) ⇔ a2 − b2 ≡ (a − b) (a + b) ≡ 0 (mod p)
⇔ p | (a − b) or p | (a + b).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
CO N G RU E N T PR O P ERT I E S O F M U LT I P L I C AT I O N ( 1 1 1 – 1 1 7 ) 117
Summary
We can use the following rules to simplify congruences:
n
(3.10) If ac ≡ bc (mod n) then a ≡ b (mod ) where g = gcd (c, n).
g
(3.11) If ac ≡ bc (mod n) and g = gcd (c, n) = 1 then a ≡ b (mod n).
(3.14) If a × b ≡ 0 (mod p) where p is prime then a ≡ 0 (mod p) or b ≡ 0 (mod p).
EXERCISES 3.2
(Brief solutions at end of book. Full 4. Give three different examples which
solutions available at <http://www.oup.co. satisfy the following:
uk/companion/NumberTheory>.) a × b ≡ 0 (mod n) implies
1. Check whether the following a ≡ 0 (mod n) or b ≡ 0 (mod n).
congruences satisfy the rule, 5. Give three different examples which
satisfy
ac ≡ bc (mod n) ⇒ a ≡ b (mod n). a × b ≡ 0 (mod p) ⇒
a ≡ b ≡ 0 (mod p)
(a) 5 × 4 ≡ 5 × 7 (mod 3) where p is prime.
(b) 9 × 12 ≡ 9 × 8 (mod 6)
(c) 6 × 11 ≡ 6 × 7 (mod 8) 6. Show that if x2 ≡ 0 (mod p) where p is
(d) 13 × 21 ≡ 13 × 7 (mod 26) prime then p | x.
(e) 13 × 31 ≡ 13 × 5 (mod 26) 7. Prove Proposition 3.14 (b).
(f) 101 × 35 ≡ 101 × 66 (mod 31)
8. Find the least non-negative residue x
2. Which integers x (general solution) modulo n in the following cases:
satisfy the following congruences?
(a) x2 ≡ 25 (mod 3)
(a) 2x ≡ 2 × 1 (mod 5) (b) x2 ≡ 100 (mod 11)
(b) 7x ≡ 7 × 3 (mod 14)
Also determine the general solution in
(c) 10x ≡ 10 × 12 (mod 6)
each case.
(d) 8x ≡ 8 × 5 (mod 48)
(e) −3x ≡ 3 × 5 (mod 21) 9. Disprove the following:
(f) −12x ≡ 12 × 7 (mod 108) (i) If gcd (x, n) = 1 and
(g) 15x ≡ 0 (mod 8) x2 ≡ 1 (mod n) then x ≡ ±1 (mod n).
3. Give three different examples which (ii) If gcd (x, n) = 1 and
satisfy the following: x2 ≡ a (mod n) then x ≡ ±a (mod n).
a × b ≡ 0 (mod n) but 10. Show that if an ≡ 0 (mod p) where p is
a ≢ 0 (mod n) and b ≢ 0 (mod n). prime then a ≡ 0 (mod p).
.........................................................................................................
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
118 3 T HE ORY OF M O D U L A R A R I T H M ET I C
2x + 1 = 7.
ax ≡ b (mod n).
The solution to this linear congruence is the set of integers x which satisfy this.
ax ≡ b (mod n)
and they are congruent modulo n, that is x0 ≡ x1 (mod n), then we say these are the same
solution and count them as one solution.
For example, let us consider the linear congruence
2x ≡ 1 (mod 5).
x 0 1 2 3 4 5 6 7 8 9
2x (mod 5) 0 2 4 1 3 0 2 4 1 3
2x ≡ 1 (mod 5).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S O LV I NG L I N E A R C O N G RU E N C E S ( 1 1 8 – 1 2 9 ) 119
Because 8 ≡ 3 (mod 5). We count this as one solution not two. [It is the same station in
modulo 5 clock.]
Since we are interested in solutions modulo 5, we only need to consider residues;
x = 0, 1, 2, 3, and 4 [least non-negative residues modulo 5].
Because all the other integers will be one of these in modulo 5, which is illustrated below:
The congruence x ≡ 0, 1, 2, 3, 4 (mod 5) covers all the stations. Any other integer will stop
at one of these junctions.
A more systematic way of solving the above linear congruence is given next.
Example 3.10
2x = 1 + 5y where y is an integer.
Re-arranging this, we have 2x − 5y = 1 which is a linear Diophantine equation; we solved these types
of equations in Section 1.4.
Making x the subject of 2x = 5y + 1 gives
5y + 1
x= .
2
Remember x must be an integer.
So what values of y can we use?
Only the odd integers, because if we choose an even number then we get even plus 1, which does not
give a whole number after dividing by 2.
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
120 3 T HE ORY OF M O D U L A R A R I T H M ET I C
5y + 1
Substituting y = 1, 3, 5, ⋯ , −1, −3, −5, ⋯ into x = gives
2
3 ≡ 8 ≡ 13 ≡ ⋯ ≡ −2 ≡ −7 ≡ ⋯ (mod 5).
See Figure 3.6 and you will notice that all these numbers 3, 8, 13, ⋯, −2, −7 stop at the same junction,
3 (mod 5).
We say the solution of 2x ≡ 1 (mod 5) is x ≡ 3 (mod 5).
Example 3.11
x = 0, 1, 2, 3, 4, and 5,
because we are working with modulo 6 in this case. Evaluating these we have:
By examining this table, we find that there are no x values which satisfy
2x ≡ 1 (mod 6).
If we have ax ≡ b (mod n) then we only have to consider the least non-negative residues:
x = 0, 1, 2, 3, ⋯ , n − 1.
In solving 2x ≡ 1 (mod 5) we tried values of x up to 9 (see Table 3.2 at the beginning of this
section), but we only need to try x = 0, 1, 2, 3, 4.
The previous Example 3.11 demonstrates that there are some linear congruences which have
no solution.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S O LV I NG L I N E A R C O N G RU E N C E S ( 1 1 8 – 1 2 9 ) 121
ax ≡ b (mod n)
In Example 3.10 we had 2x ≡ 1 (mod 5). The g = gcd (2, 5) = 1 and 1 | 1 so the linear
congruence 2x ≡ 1 (mod 5) has a solution.
On the other hand, in Example 3.11 we had 2x ≡ 1 (mod 6) the g = gcd (2, 6) = 2 and 2
does not divide 1, so there are no solutions to this linear congruence. (For this example you
would have noticed from the previous table that 2x (mod 6) only stops at 0, 2, and 4 modulo
6 because these numbers are multiples of g = gcd (2, 6) = 2.)
Proof.
We have ax ≡ b (mod n) which means that there is an integer y such that
ax = b + ny implies ax − ny = b.
Let g = gcd (a, n). Then by Proposition (1.17) we conclude that the Diophantine equation
ax − ny = b
Example 3.12
Solution
(a) The greatest common divisor of 7 and 14, that is gcd (7, 14) = 7, but 7 does not divide 8, so by
the previous Proposition (3.15) the linear congruence 7x ≡ 8 (mod 14) has no solution.
(b) For 12x ≡ 8 (mod 6) the gcd (12, 6) = 6 but 6 8, therefore 12x ≡ 8 (mod 6) has no solution.
(c) For 15x ≡ 21 (mod 9) we have gcd (15, 9) = 3 and 3 divides 21 so the given linear congruence
15x ≡ 21 (mod 9) has solutions (we are not asked to find them).
(d) The gcd (36, 90) = 18 and 18 divides 54 so the given linear congruence 36x ≡ 54 (mod 90) has
solutions.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
122 3 T HE ORY OF M O D U L A R A R I T H M ET I C
We will show that the congruence ax ≡ b (mod n) has exactly g = gcd (a, n) incongruent
solutions.
Why?
Because 1 (mod 4) and 3 (mod 4) are two different stops on the modulo 4 clock.
Example 3.13
Solution
We first find the greatest common divisor of 6 and 9:
gcd (6, 9) = 3.
Since 3 | 3, the given linear congruence 6x ≡ 3 (mod 9) has (exactly three) solutions.
In this case we are working with modulo 9, so we only need to consider
x = 0, 1, 2, 3, 4, 5, 6, 7, and 8.
x ≡ 2, 5, 8 (mod 9).
6x ≡ 0, 3, 6 (mod 9)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S O LV I NG L I N E A R C O N G RU E N C E S ( 1 1 8 – 1 2 9 ) 123
have solutions because all these numbers—0, 3, 6 —are multiples of 3, which is the gcd of
6 and 9. The set of integers represented by 6x (mod 9) only stops at junctions 0, 3, 6 on the
modulo 9 clock.
Therefore, the following congruence equations 6x ≡ 1, 2, 4, 5, 7, and 8 (mod 9) will
have no solutions because 3 does not divide into any of these numbers 1, 2, 4, 5, 7, and 8.
ax ≡ b (mod n)
has exactly g incongruent solutions modulo n, provided g | b where g = gcd (a, n).
Proof.
See Exercises 3.3, question 24.
In the proof of this Proposition (3.16), a list is used to find the g solutions of
ax ≡ b (mod n). It is given by the following formula where x0 is an initial solution:
n n n n
(3.17) x ≡ x0 , x0 + ( ) , x0 + 2 ( ) , x0 + 3 ( ) , ⋯ , x0 + ( g − 1) ( ) (mod n).
g g g g
These residues can be written in compact form as:
n
(3.18) x ≡ x0 + t ( ) (mod n) for t = 0, 1, 2, ⋯ , g − 1.
g
7x − 35 = 0,
We can divide through by the gcd (a, n) to find possible solutions of ax ≡ b (mod n)
because then we are dealing with a smaller modulo which is simpler to work with.
The next example demonstrates this.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
124 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Example 3.14
Solution
First, we determine the greatest common divisor, gcd, of 7 and 70 which is
We need to check that 7 divides into 35. Since 7 | 35, so we have seven incongruent solutions.
Why?
Because by Proposition (3.16):
7x ≡ 5 × 7 (mod 10 × 7).
x ≡ 5 (mod 10).
From the definition of congruence we have x − 5 = 10y or x = 5 + 10y. Recall we have seven incon-
gruent solutions, so substituting y = 0, 1, 2, 3, 4, 5, and 6 into x = 5 + 10y gives
You can check that all these satisfy the given congruence 7x ≡ 35 (mod 70).
We can also solve the congruence of Example 3.14 by the formula given earlier:
n
(3.18) x ≡ x0 + t ( ) (mod n) for t = 0, 1, 2, ⋯ , g − 1.
g
Solving 7x ≡ 35 (mod 70) with the initial solution x0 ≡ 5 (mod 70).
S O LV I NG L I N E A R C O N G RU E N C E S ( 1 1 8 – 1 2 9 ) 125
Example 3.15
Solution
First gcd (7, 70) = 7, but 7 does not divide into 34, therefore there are no solutions to
7x ≡ 34 (mod 70).
Example 3.16
5x ≡ 34 (mod 7).
Solution
The gcd (5, 7) = 1, and 1 divides into 34.
How many solutions do we have of the given linear congruence?
One solution (unique solution).
How can we find this?
We can simplify the given congruence 5x ≡ 34 (mod 7) to make the arithmetic easier; note
that 34 ≡ 6 (mod 7), therefore 5x ≡ 34 ≡ 6 (mod 7). It is simpler to solve
Also note that 5 ≡ −2 (mod 7) and 6 ≡ −1 (mod 7). Using these results implies that we can solve
the equivalent easier equation:
−2x ≡ −1 (mod 7)
2x ≡ 1 (mod 7) [Multiplying by − 1] .
5 (4) ≡ 20 ≡ 6 ≡ 34 (mod 7) .
Example 3.17
6x ≡ 34 (mod 68).
Solution
The gcd (6, 68) = 2 and 2 | 34, so there are two incongruent solutions modulo 68.
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
126 3 T HE ORY OF M O D U L A R A R I T H M ET I C
If you only have paper and pen, then modulo 68 is too tedious to work with.
n
a × c ≡ b × c (mod n) implies a ≡ b (mod ) where g = gcd (c, n).
g
From this last congruence 3x ≡ 17 (mod 34) we have the Diophantine equation:
17 + 34y
3x = 17 + 34y ⇒ x = for integer y.
3
17 + 34y 17 + 34 (1)
Substituting y = 1 into this x = gives x = = 17. Recall we have two incongruent
3 3
solutions.
How do we find the other one?
From this solution x ≡ 17 (mod 34) we have (x is 17 more than a multiple of 34):
x = 17 + 34y where y is an integer.
What are values of y?
Since we have two solutions, so substituting y = 0, 1 into x = 17 + 34y gives
These are the two incongruent solutions modulo 68. Check these in your own time.
If gcd (a, n) = 1 then how many solutions does the general linear congruence ax ≡ b (mod n) have?
Just one, a unique solution because g is the number of solutions of ax ≡ b (mod n), provided
g divides b. We can write this as a general result.
Corollary (3.19). If gcd (a, n) = 1 then the linear congruence ax ≡ b (mod n) has a unique
solution modulo n.
Proof.
Applying Proposition (3.16) with g = 1:
ax ≡ b (mod n) has exactly g solutions, provided g | b where g = gcd (a, n).
We are given g = gcd (a, n) = 1 and 1 | b, so we have a unique solution to ax ≡ b (mod n).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S O LV I NG L I N E A R C O N G RU E N C E S ( 1 1 8 – 1 2 9 ) 127
Example 3.18
Solution
Since gcd (6, 13) = 1, so we have a unique solution modulo 13. The congruence 6x ≡ 1 (mod 13)
implies that we have the Diophantine equation:
1 + 13y
6x = 1 + 13y which implies x = where y is an integer.
6
1 + 13 (5)
We choose y so that x is an integer. Let y = 5 then x = = 11. Hence
6
x ≡ 11 (mod 13).
1 1
In ordinary algebra we have 6x = 1 ⇒ x = . This x = 6−1 = is the inverse of 6. Simi-
6 6
larly, the unique solution of the above congruence 6x ≡ 1 (mod 13) is
x ≡ 11 (mod 13).
Definition (3.20). If ax ≡ 1 (mod n) then the unique solution x of this congruence is called
the multiplicative inverse of a modulo n and is denoted by a−1 (mod n).
Example 3.19
Solution
To find the inverse means we need to solve 3x ≡ 1 (mod 14). The gcd (3, 14) = 1, so 3−1 (mod 14)
exists. By inspection
The inverse of 3 modulo 14 is 5 modulo 14, or in notation form 3−1 ≡ 5 (mod 14).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
128 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Example 3.20
Solution
In this case we need to solve 3x ≡ 1 (mod 15). The gcd (3, 15) = 3, so there are no solutions to this
congruence 3x ≡ 1 (mod 15).
Therefore, 3 modulo 15 has no inverse, or we say the inverse does not exist.
Recall Proposition (3.21), which says that a (mod n) has an inverse if and only if
gcd (a, n) = 1.
This implies that only the relative prime residues to n have inverses.
1, 3, 7, and 9.
The residues 0, 2, 4, 5, 6, and 8 will not have inverses modulo 10 because they are not
relatively prime with 10.
If a−1 ≡ a (mod n) then we say that a is self-invertible, or has its own inverse. For exam-
ple, 12−1 ≡ 12 (mod 13) because 12 × 12 ≡ 144 ≡ 1 (mod 13).
Summary
(3.15) and (3.16) ax ≡ b (mod n) has solutions ⇔ g | b where g = gcd (a, n) and it has g incongruent
solutions.
The multiplicative inverse of a modulo n is the unique solution x (mod n) of ax ≡ 1 (mod n) and is
denoted by a−1 (mod n).
EXERCISES 3.3
S O LV I NG L I N E A R C O N G RU E N C E S ( 1 1 8 – 1 2 9 ) 129
3. Find all the solutions of the following 10. Give an example of a linear
linear congruences: congruence ax ≡ b (mod n) where
integer d > 1 divides a, n, and b but the
(a) 6x ≡ 2 (mod 4)
equation has no solutions.
(b) 12x ≡ 6 (mod 18)
(c) 15x ≡ 10 (mod 25) 11. Let p be prime. Show that a modulo
(d) 7x ≡ 21 (mod 1001) p has its own inverse ⇔
a ≡ ±1 (mod p).
4. Which of the following congruences
equations have no solutions? If any of 12. Show that if a−1 ≡ b (mod n) then
these have solutions, find them. b−1 ≡ a (mod n) .
(a) 12x ≡ 4 (mod 18) 13. Prove Proposition (3.21).
(b) 13x ≡ 5 (mod 65)
(c) 18x ≡ 1 (mod 16) 14. Show that the linear congruence
(d) 1001x ≡ 121 (mod 11) ax ≡ b (mod n) where gcd (a, n) = 1
(e) 15x ≡ 9 (mod 27) has the unique solution given by
(f) 407x ≡ 40 (mod 666)
x ≡ a−1 b (mod n).
5. Find all solutions of the following
congruences: Determine 9−1 (mod 21).
(a) 10x ≡ 20 (mod 15) 15. Show that every integer a such that
(b) 12x ≡ 18 (mod 48) 1 ≤ a < p where p is prime has a
(c) 12x ≡ 48 (mod 18) multiplicative inverse modulo p.
6. Consider the linear congruence 16. Show that none of the elements in
15x ≡ b (mod 25). Find the integers b {2, 3, ⋯ , p − 2} modulo p are
for which this linear congruence has self-invertible.
solutions. (Self-invertible means
a−1 ≡ a (mod n).)
How many incongruent solutions does it have?
17. Show that the equation
7. Consider the linear congruence n (a + b) x ≡ [a2 − b2 ] (mod (a + b))
equation nx ≡ b (mod n2 ) where n ≥ 1. has solutions.
Determine the integers b for which
there are solutions and state the How many solutions does this equation
number of solutions. have?
8. Find the multiplicative inverses of the 18. Show that the equation
following:
a n
(a) 6 (mod 13) (b) 5 (mod 6) x ≡ b (mod )
g g
(c) 12 (mod 17) (d) 16 (mod 17)
*(e) 9 (mod 101) (f) n + 1 (mod n) where g = gcd (a, n) has solutions.
9. Determine the integers a which have a How many solutions does this equation
multiplicative inverse: have?
(a) modulo 12 (b) modulo 13 19. Solve the linear Diophantine equation
(c) modulo 15. 15x − 6y = 3. Using your solutions to
this equation, solve 15x ≡ 3 (mod 6).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
130 3 T HE ORY OF M O D U L A R A R I T H M ET I C
23. This is a question on cryptography— Find a (mod pq) and show that
secure communication.
M ≡ ad (mod pq) .
Let p = 11, q = 13, and e = 17. Bob’s
public key is given by the two numbers 24. **Prove Proposition (3.16).
p × q and e. Bob’s private key, the
number d, satisfies
.........................................................................................................
C H I N ES E R E M A I N D E R T H E O R E M ( 1 3 0 – 1 4 0 ) 131
ax ≡ b (mod n).
In this section we examine solving a set of simultaneous linear congruences. We’ll begin by
looking at an example before going on to develop the general method.
Example 3.21
x ≡ 1 (mod 5) (1)
x ≡ 4 (mod 7) (2)
Solution
We need to find a value of x such that equations (1) and (2) are true. Let us first use brute force:
x 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
x(mod 5) 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0
x(mod 7) 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1
From Table 3.5 the value of x that satisfies both our equations is x = 11 because
Of course, we can apply brute force for simple integer values. However, we need a sys-
tematic way to solve these because modulo n may be a large number.
What does the first equation x ≡ 1 (mod 5) in the above example mean?
x = 1 + 5k = 4 + 7c
3 + 7c
k= .
5
Since k is an integer, we need 3 + 7c to be a multiple of 5. If c = 1 then
3 + 7c 3 + 7 (1) 10
k= = = = 2.
5 5 5
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
132 3 T HE ORY OF M O D U L A R A R I T H M ET I C
x = 4 + 7 (1) = 11.
Example 3.22
x ≡ 31 (mod 49)
x ≡ 6 (mod 20)
Solution
From these equations and definition of congruence we have
where k and c are integers. Equating these last two equations because both are equal to x gives the
Diophantine equation:
25 + 49k
6 + 20c = 31 + 49k implies c = .
20
Since we want integer solutions, so we try values of k such that the numerator 25 + 49k is a multiple
of 20. (Multiplying 49 by multiples of 5 will give results ending in 5 or 0. Only results ending in 5 will
be divisible by 20 after adding 25.)
Hence we trial multiples of 5 for k, that is k = 5, 10, 15, ⋯. Note that k = 5, 10 does not give a
multiple of 20 but 15 does, because
25 + 49 (15)
c= = 38.
20
Substituting c = 38 into x = 6 + 20c gives x = 6 + 20 (38) = 766.
Checking that this x = 766 satisfies both the given equations:
Example 3.23
Solution
We can write the integer x satisfies the following congruence equations:
C H I N ES E R E M A I N D E R T H E O R E M ( 1 3 0 – 1 4 0 ) 133
You may check that each of these solutions satisfies the given equations:
In the next subsection we encounter the Chinese remainder theorem which provides us
with a structured way of solving simultaneous linear congruence equations.
From the previous example we say the numbers 2, 3, and 5 are pairwise (relatively) prime.
It means that the only factor in common between any pair of numbers is 1:
Hence 2, 3, and 5 are pairwise prime. (We discussed pairwise prime in Section 2.4).
Be careful; it is not good enough just to say if gcd (a, b, c) = 1 then a, b, and c are
pairwise prime.
For example, gcd(2, 3, 4) = 1 but gcd(2, 4) = 2. The integers 2, 3, and 4 are not pairwise
prime.
Let n1 , n2 , n3 , ⋯ , nr be integers such that any two of these numbers do not have a com-
mon factor apart from 1, that is
gcd(ni , nj ) = 1 for i ≠ j.
gcd (25, 26) = 1, gcd (26, 27) = 1, and gcd (25, 27) = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
134 3 T HE ORY OF M O D U L A R A R I T H M ET I C
x ≡ a1 (mod n1 )
x ≡ a2 (mod n2 )
⋮
x ≡ ar (mod nr )
We need to show two things: (1) existence of solution and (2) uniqueness of solution.
Proof.
(1) Existence
Let n = n1 × n2 × n3 × ⋯ × nr . For each integer k = 1, 2, 3, ⋯ , r, let
This means that Nk is the product of all the given moduli ni with the number nk missing.
Since the nk ’s are pairwise prime, so gcd (ni , nj ) = 1 for i ≠ j, which implies that
Why?
Nk x ≡ 1 (mod nk ).
Yes, it has a unique solution because gcd (nk , Nk ) = 1. Let xk be the unique solution of
Nk x ≡ 1 (mod nk ) for each k, which implies that
Nk xk ≡ 1 (mod nk ) (†)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
C H I N ES E R E M A I N D E R T H E O R E M ( 1 3 0 – 1 4 0 ) 135
x ′ = a1 N1 x1 + a2 N2 x2 + a3 N3 x3 + ⋯ + ar Nr xr .
x ≡ a1 (mod n1 ).
x ′ ≡ a1 N1 x1 + a2 N2 x2 + a3 N3 x3 + ⋯ + ar Nr xr (mod n1 ). (∗)
x ′ ≡ a1 N1 x1 + 0 + 0 + ⋯ + 0 ≡ a1 N1 x1 (mod n1 ).
By the above (†) we have N1 x1 ≡ 1 (mod n1 ). Substituting this into the above
x ′ ≡ a1 N1 x1 (mod n1 ) gives
x ′ ≡ a1 N1 x1 ≡ a1 (1) ≡ a1 (mod n1 ).
Hence x ′ satisfies the first congruence equation x ≡ a1 (mod n1 ). Arguing along very sim-
ilar lines we can show that the solution constructed, x ′ , satisfies the remaining congruence
equations. Therefore, there is a solution to all the given congruences, x = x ′ .
(2) Uniqueness
Suppose there is another solution, y, which satisfies the given equations. This means we
have
x ≡ ak ≡ y (mod nk ) for k = 1, 2, 3, ⋯ , and r.
From this congruence x ≡ y (mod nk ) for k = 1, 2, 3, ⋯ , and r we have
n1 | (x − y) , n2 | (x − y) , ⋯ , nr | (x − y). (††)
Remember we are given that the nk ’s are pairwise prime: gcd (ni , nj ) = 1 for i ≠ j.
Applying the result of Exercises 1.3, question 12 (ii):
if a1 | c, a2 | c, ⋯ , an | c with gcd (aj , ai ) = 1 then (a1 × a2 × ⋯ × an ) | c,
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
136 3 T HE ORY OF M O D U L A R A R I T H M ET I C
(n1 × n2 × n3 × ⋯ × nr ) | (x − y).
The proof gives us a systematic way of constructing the solutions of any given linear
simultaneous congruences. In the proof the solution we constructed was given by:
(3.23) x = a1 N1 x1 + a2 N2 x2 + a3 N3 x3 + ⋯ + ar Nr xr .
1. The ak ’s are the numbers on the right-hand side of the given equations
x ≡ ak (mod nk ).
2. The upper case Nk ’s are product of the given moduli with nk missing:
Nk = n1 × n2 × ⋯ × nk−1 × nk+1 × ⋯ × nr .
Nk xk ≡ 1 (mod nk ).
Example 3.24
Let us now solve the soldiers problem stated at the beginning of this section. Recall this problem was
equivalent to solving the simultaneous equations:
Find the exact number of soldiers, given that there are between 500 and 600 soldiers.
Solution
How do we solve this problem?
We use the above formula:
(3.23) x = a1 N1 x1 + a2 N2 x2 + a3 N3 x3 + ⋯ + ar Nr xr .
C H I N ES E R E M A I N D E R T H E O R E M ( 1 3 0 – 1 4 0 ) 137
We can only use this formula if the given moduli 3, 5, and 7 are pairwise prime:
Therefore,
3 ×5×7
/
N1 = = 35 [3 missing in the product]
/3
3 ×/5 ×7
N2 = = 21 [5 missing in the product] .
/5
3 × 5 ×/
7
N3 = = 15 [7 missing in the product]
/7
We need to find the xk ’s which satisfy Nk xk ≡ 1 (mod nk ) for k = 1, 2, and 3:
N1 x1 ≡ 35x1 ≡ 1 (mod 3)
N2 x2 ≡ 21x2 ≡ 1 (mod 5)
N3 x3 ≡ 15x3 ≡ 1 (mod 7).
We are required to find the number x1 which satisfies 35x1 ≡ 1 (mod 3). Note that 35 ≡ 2 (mod 3), so
we have:
35x1 ≡ 2x1 ≡ 1 (mod 3) implies x1 = 2.
Similarly, solving the other two equations:
21x2 ≡
⏟ x2 ≡ 1 (mod 5) implies x2 = 1.
Because 21≡1(mod 5)
15x3 ≡
⏟ x3 ≡ 1 (mod 7) implies x3 = 1.
Because 15≡1(mod 7)
We have x = 233, satisfying all the given simultaneous equations. However, there may be a smaller
number which also satisfies all the equations.
How can we find this number?
In the proof we are given that the solution is unique modulo n1 × n2 × n3 × ⋯ × nr . In our case we
have
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
138 3 T HE ORY OF M O D U L A R A R I T H M ET I C
n1 × n2 × n3 = 3 × 5 × 7 = 105.
Hence x = 233 ≡ 23 (mod 105). The general solution x is given by
x = 23 + 105t.
Next, we expand the Chinese remainder theorem to cover linear congruences of the type
cx ≡ b (mod n) because (3.23) only applies to congruences like x ≡ b (mod n).
Proposition (3.24). Let n1 , n2 , n3 , ⋯ , nr be positive integers which are pairwise prime. Also,
integers ck ’s satisfy gcd (ck , nk ) = 1 for k = 1, 2, ⋯ , n. Then the simultaneous linear con-
gruences
c1 x ≡ b1 (mod n1 )
c2 x ≡ b2 (mod n2 )
⋮
cr x ≡ br (mod nr )
Proof.
See Exercises 3.4, question 9.
Example 3.25
Solution
This time we do not have x ≡ ? (mod m), but cx ≡ ? (mod m).
How do we solve these?
We convert them into x ≡ ? (mod m) by first multiplying each of these equations by an appropriate
factor. Multiplying the first congruence 2x ≡ 1(mod 5) by 3 gives
6x ≡
⏟ x ≡ 3(mod 5).
Because 6≡1(mod 5)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
C H I N ES E R E M A I N D E R T H E O R E M ( 1 3 0 – 1 4 0 ) 139
We can simplify the second equation 3x ≡ 9 (mod 6) by dividing through by gcd (3, 6) = 3:
3 9 6
x ≡ (mod ) implies x ≡ 3 ≡ 1 (mod 2).
3 3 3
We multiply the third given equation 4x ≡ 1 (mod 7) by 2:
8x ≡
⏟ x ≡ 2 (mod 7).
Because 8≡1(mod 7)
x = a1 N1 x1 + a2 N2 x2 + a3 N3 x3 + ⋯ + ar Nr xr .
14x1 ≡
⏟ −x1 ≡ 1 (mod 5) implies x1 = 4.
Because 14≡4≡−1(mod 5)
140 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Check that x ≡ 23 (mod 70) satisfies the three given simultaneous equations:
Summary
To solve simultaneous congruence equations, we apply the Chinese remainder theorem to resolve for
the unknown.
EXERCISES 3.4
I N T RO D U C T I O N TO FAC TO R I Z AT I O N ( 1 4 1 – 1 5 2 ) 141
.........................................................................................................
We discussed this in Section 2.1 under the importance of primes. We repeat some of this
information here.
Factorizing integers is critical in cryptography, because frequently encryption requires
us to multiply two large prime numbers, say p and q, to get their product n = p × q. This
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
142 3 T HE ORY OF M O D U L A R A R I T H M ET I C
product n = pq is not a secret but the two large primes p and q are. The idea of a product,
n = pq, being public but the factors, p and q, being secret forms the basis of public key
cryptography. To decrypt a message encrypted this way you have to find the factors (large
primes) p and q which multiply to give n. To crack this code, you need to factorize n, which
is not easy.
For example, consider the primes p = 19 993 445 929 and q = 4 567 834 463 then
n = p × q = 19 993 445 929 × 4 567 834 463 = 913 267 512 161 460 517.
Try factorizing n = 913 267 512 161 460 517 without having the knowledge that this
number is the product of the primes p and q.
For small numbers, factorizing can be done fairly quickly by hand through trial and error.
However, as the number gets larger, it becomes a very labour-intensive approach. Consider,
for example, factorizing 13 081. We could start with the first few primes 2, 3, 5, 7, 11,
13, … and see if they divide into 13 081. After sufficient attempts we arrive at
So, we would have to go through the primes 2, 3, 5, … , 103 before we found any factors of
13 081—and 13 081 is a small number. We will show later in Example 3.26 how to obtain
this factorization of 13 081.
For large composite integers, factorization is time-consuming; an important question in
number theory and cryptography is:
It could take a couple of seconds, minutes, hours, days, months, years, etc. In 1977 Martin
Gardner wrote an article titled ‘A new kind of cipher that would take millions of years to
break’.1 The article gave a product of two secret large primes which was 129 digits long. It
was eventually cracked in 1993–4 by Atkins, Graff, et al., with 600 volunteers using 1600
machines.2
The article describes an algorithm called RSA which computers use to encrypt and de-
crypt messages. RSA stands for the surnames of Ron Rivest, Adi Shamir, and Leonard
Adleman who were academics at Massachusetts Institute of Technology (MIT) in 1977.
Adleman was a number theorist and Shamir and Rivest were computer scientists at MIT.3
At the time of publication of Gardner’s article, the acronym RSA was not used. (One of the
first appearances of the acronym RSA seems to be in 1979, in a paper by Ron Rivest.)
Even with computers, factorizing large composite numbers can take long periods of time.
Much effort has been spent trying to write codes and find mathematical shortcuts to get
around this. For the time being, due to the long periods involved for factorizing, public key
cryptography is a reliable way to protect data.
1
https://simson.net/ref/1977/Gardner_RSA.pdf.
2
The Joy of Factoring by Samuel S. Wagstaff, page 5 and Section 8.2.
3
https://blogs.ams.org/mathgradblog/2014/03/30/rsa/.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N T RO D U C T I O N TO FAC TO R I Z AT I O N ( 1 4 1 – 1 5 2 ) 143
If we could find a quick and efficient way of factorizing integers then we could crack the
RSA encryption, which is the most used public encryption method at present. This is one
way of becoming a millionaire (but maybe doing so is morally questionable: do you make
things safer by pointing out a security flaw?).
However, in 2002 three Indian computer scientists, Agrawal, Kayal, and Saxena, showed
that testing an integer for primality can be done in polynomial time (this jargon means
it is an efficient algorithm).4 Note that this is just testing whether an integer is prime or
composite and not factorizing the integer, which up to now does not have an efficient
algorithm.
Throughout our mathematical careers we have used the method of difference of two squares
to solve quadratic equations. But at its heart lies an elegant way of expressing an odd integer
n, as the following demonstrates.
Let n = 391, then we could try to use the fundamental identity of algebra—the difference
of two squares:
n = a2 − b2 = (a − b) (a + b).
We need to find a way of writing 391 as the difference of two squares a2 − b2 . Since we
are interested in squares, we need to first evaluate the square root of 391:
Hence 391 is not a perfect square number. As such, we look for the smallest perfect square
which is greater than 391.
Why?
Because we want to write 391 = a2 − b2 , so we let a be the ceiling function (remember: the
ceiling function of x denoted ⌈x⌉ is the nearest integer ≥ x) of √391:
4
https://en.wikipedia.org/wiki/AKS_primality_test.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
144 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Hence we have
Both 17 and 23 are prime, therefore the prime factorization of 391 is 17 × 23.
Example 3.26
Solution
Let n = 13 081, then we could try to use the difference of two squares:
n = a2 − b2 = (a − b) (a + b).
We need to express n = 13 081 as a2 − b2 so that we can use this fundamental identity. To use this, we
need to find the square root of n = 13 081 and then take the ceiling function of this number, because
we wish to subtract n from it. Let
Since we are using the ceiling function, a2 = 1152 = 13 225 is greater than n = 13 081, their difference
being
a2 − n = 1152 − 13 081 = 144 = 122 .
2
Re-arranging this, we have 115 − 122 = 13 081 = n. Using the difference of two squares,
Now factorizing 103 and 127 is not too difficult because of their small size.
We only need to test the primes below 10 because of Corollary (2.10):
Let p be a prime factor of 103 then p ≤ ⌊√103⌋ = 10. Since none of the primes below 10 go into
103, it follows by Corollary (2.10) that the integer 103 is prime.
Similarly, 127 is prime because none of the primes 2, 3, 5, 7, and 11 go into 127.
This concept of factoring a given number n as the difference of two squares was developed
by the French mathematician Fermat (1601–65). More on the life of Fermat can be found
in the next chapter.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N T RO D U C T I O N TO FAC TO R I Z AT I O N ( 1 4 1 – 1 5 2 ) 145
We may have to take various attempts to write a given integer as the difference of two
squares. The following example outlines how we deal with such numbers.
Example 3.27
Solution
Let n = 12 371, then we need to find integers a and b such that
n = 12 371 = a2 − b2 .
We can rewrite this as b2 = a2 − 12 371. First, we find the ceiling function of the square root of
12 371:
⌈√12 371⌉ = ⌈111.22⌉ = 112 = a1 .
Rewriting 12 371 as a difference of two squares, 12 371 = a21 − b21 = 1122 − b21 .
Re-arranging this 12 371 = 1122 − b21 , we have
Since 173 is not a perfect square, we trial the next integer after 112 which is 113, with
1132 − 12 371 = 398. Again 398 is not a square number. Therefore, we trial the next integer:
1142 − 12 371 = 625 and 625 = 252 . Now that we have a square number we can write:
Now factorizing these numbers 89 and 139 is much easier than trying to factorize the given number
12 371 because of their relatively small size.
It can be shown that both 89 and 139 are prime (you should check this). Hence
12 371 = 89 × 139.
146 3 T HE ORY OF M O D U L A R A R I T H M ET I C
n+1 2 n−1 2
( ) −( ) = n.
2 2
This means we can write every odd integer n as the difference of two integer squares.
(You are asked to show this identity in Exercises 3.5, question 3.)
Therefore, for any odd positive integer n we have
n+1 n−1
a2 − b2 = n where a = and b = .
2 2
The French amateur mathematician Fermat used this method to factorize 2 027 651 281
(see Supplementary Problems 3, question 19).
The Fermat factorization method described above is quite effective if n has factors
close to √n.
For example, the non-trivial factors of 12 are 2, 3, 4, and 6. Clearly 1 and 12 are factors
of 12, but these are the trivial factors of 12.
2, 4, 5, and 10.
Next, we state the Factorization Theorem:
Factorization Theorem (3.26). Let a and b be integers which satisfy the congruence
I N T RO D U C T I O N TO FAC TO R I Z AT I O N ( 1 4 1 – 1 5 2 ) 147
202 ≡ 32 (mod 391) and 20 ≢ ±3 (mod 391) [In this case a = 20, b = 3, n = 391].
Evaluating gcd (20 − 3, 391) = gcd (17, 391) = 17, and so by the above Factorization Theo-
rem (3.26) we have that 17 is a factor of 391. Actually, 391 = 17 × 23.
Note that the two factors of 391 are 20 − 3 = 17 and 20 + 3 = 23. (We found these factors,
17 and 23, earlier in this section.)
Proof.
Let g = gcd (a − b, n). By the definition of greatest common divisor (gcd) we know that g is
a factor of n. However, we need to prove that g is a non-trivial factor of n.
Therefore, we must show that g ≠ n and g ≠ 1.
Case I: First we prove g ≠ n.
We have a2 ≡ b2 (mod n) but a ≢ b (mod n), which implies n (a − b). Hence
g = gcd (a − b, n) ≠ n.
What advantage is there of using this congruence a2 ≡ b2 (mod n) rather than the well-known
identity, the difference of two squares: a2 − b2 = n?
148 3 T HE ORY OF M O D U L A R A R I T H M ET I C
Example 3.28
Solution
Let n = 12 349. We need to find integers a and b such that
If k = 1 then we have our difference of two squares. Let us first try to tackle this problem as the
difference of two squares. We find the ceiling function of the square root of 12 349:
Now 1122 − 12 349 = 195. Clearly 195 is not a perfect square because
Let f (ak ) = a2k − 12 349 be a function where ak is our trial integer. Creating a table by selecting some
values just above 112 and finding the factors of a2k − 12 349, we obtain:
Table 3.6
I N T RO D U C T I O N TO FAC TO R I Z AT I O N ( 1 4 1 – 1 5 2 ) 149
gcd (a − b, n) = gcd (1 626 748 − 40 950, 12 349) = gcd (1 585 798, 12 349).
By using the Euclidean Algorithm (Section 1.3) we can find this gcd:
932 = (4 × 233)
Hence gcd (1 585 798, 12 349) = 233. Therefore, by the Factorization Theorem (3.26):
Note that the factors 53 and 233 are not close to ⌈√12 349⌉ = 112.
This may be a time-consuming way to factorize an integer, but there is no easy way to
factorize integers. It is the matching of squares that takes time.
Many computer factorization algorithms exist, each of which has its own advantages and
disadvantages. However, it remains true that to date there is no rapid, foolproof method for
factorizing large integers.
Summary
We can use the difference of two squares a2 − b2 = (a − b) (a + b) to factorize integers.
Also, if a2 ≡ b2 (mod n) and a ≢ ±b (mod n) then gcd (a − b, n) is a non-trivial factor of n.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
150 3 T HE ORY OF M O D U L A R A R I T H M ET I C
EXERCISES 3.5
(Brief solutions at end of book. Full 10. (i) Show that 3n − 1 is a composite
solutions available at <http://www.oup.co. integer for n > 1.
uk/companion/NumberTheory>.)
(ii) Show that xn − 1 is a composite
1. Factorize the following integers into integer for n > 1 and x ≥ 3.
their prime factors: [Hint: an − bn = (a − b) (an−1 +
n−3
(a) 299 (b) 851 an−2 b + a b2 + ⋯ + abn−2 + bn−1 )
(c) 10 403 (d) 2479 for n > 1.]
2. Factorize the following into their 11. Trapdoor functions are used in
prime factors: cryptography because it is a function
(a) 9271 (b) 2146 *(c) 2 974 791 which is easily evaluated in one
3. Let n be an odd integer. Show that direction but difficult to evaluate in the
n+1 2 n−1 2 reverse direction. An example is
( ) −( ) = n. multiplication of two primes, p and q,
2 2
which can be carried out easily to
4. Factorize 1 236 519.
produce a number n = p × q, but to
5. (i) Factorize each of the following factorize n = p × q is difficult.
integers:
Factorize the following trapdoor
(a) 713 (b) 1271 (c) 403 functions (these small numbers are not
(ii) Solve the quadratic equation good candidates for the trapdoor
functions) into two primes:
403x2 + 1271x + 713 = 0
(a) 411 (b) 2419 (c) 17 947
leaving your answer in surd form.
12. Factorize the following integers using
(iii) Simplify the following fractions: modular arithmetic:
713 403 403
, , and . (a) 2201 *(b) 2189 (c) 9211
1271 1271 713
13. What type of integer n do we have if:
6. Factorize 18 861 649. Hence or
otherwise solve the quadratic a2 ≡ b2 (mod n) ⇒ a ≡ ±b (mod n) ?
.........................................................................................................
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N T RO D U C T I O N TO FAC TO R I Z AT I O N ( 1 4 1 – 1 5 2 ) 151
Supplementary Problems 3
(Brief solutions at end of book. Full 3.7. Prove the following statements:
solutions available at <http://www.oup.co. (a) If n is odd then
uk/companion/NumberTheory>.) n2 ≡ 1 (mod 8).
3.1. Determine whether the following are (b) For any n we have
true or false: n3 ≡ 0, 1, 6 (mod 7).
(c) For any n we have
(a) 2015 ≡ 5 (mod 10)
n4 ≡ 0 or 1 (mod 5).
(b) 266 ≡ 1 (mod 7)
(c) 17 ≡ −5 (mod 12) 3.8. Prove that every square number is
(d) −11 ≡ −57 (mod 34) congruent to 0 or 1 (mod 4).
(e) a ≡ 0 (mod 1) where a is any 3.9. Prove that if a ≡ b (mod n) and c > 0
integer. then ac ≡ bc (mod nc).
3.2. Find all solutions of the following 3.10. Prove that if a ≡ b (mod n) and
congruences: d | a, d | b and d | n where d is a posi-
a b n
(a) 7x ≡ 21 (mod 15) tive integer then ≡ (mod ).
d d d
(b) 12x ≡ 24 (mod 27)
3.11. Let p be prime such that p a. Show
(c) 10x ≡ 20 (mod 30)
that if ap ≡ a (mod p) then
(d) 3x ≡ 2 (mod 6)
ap−1 ≡ 1 (mod p).
3.3. Determine the multiplicative inverse
3.12. Give an example of the following:
of the following:
Let p be prime and x2 ≡ 1 (mod p)
(a) 5 (mod 12) (b) 7 (mod 15)
implies that both x − 1 ≡ 0 (mod p)
(c) 10 (mod 27) (d) 6 (mod 15)
and x + 1 ≡ 0 (mod p).
(e) 7 (mod 12) (f) 11 (mod 12)
(g) 9 (mod 13) (h) 9 (mod 15) 3.13. (a) Solve the following simultaneous
linear congruences:
3.4. Which least non-negative residues
have no multiplicative inverse x ≡ 1 (mod 3), x ≡ 2 (mod 4),
modulo 12? x ≡ 3 (mod 5).
3.5. Find the prime decomposition of (b) Suppose a teacher divides
48 531. students for group work and the
3.6. Let p be prime and a, b, n, and m be following applies:
natural numbers. Prove or disprove When divided into groups of three
the following statements: students one is left over.
(a) If n ≡ 0 (mod pa ) then When divided into groups of five
n ≡ 0 (mod pa+1 ). students three are left over.
(b) If pa ≡ 0 (mod n) then When divided into groups of seven
pa+1 ≡ 0 (mod n). students five are left over.
a
(c) If p ≡ 0 (mod n) then
What is the minimum number of
pa+m ≡ 0 (mod n).
a students in the class?
(d) If p ≡ 0 (mod n) and
pb ≡ 0 (mod m) then 3.14. Let p and q be distinct primes.
pmin(a, b) ≡ 0 (mod m + n) where Disprove the following:
min(a, b) is the smaller of the two If ap ≡ a (mod p) and
values and a ≠ b. aq ≡ a (mod q) then
apq ≡ a (mod pq).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
152 3 T HE ORY OF M O D U L A R A R I T H M ET I C
3.15. *Let gcd (a, n) = 1 and k be the 3.20. *Provide another proof of
smallest positive integer such that Factorization Theorem (3.26).
ak ≡ 1 (mod n). Prove that 3.21. Show that x5 (mod 7) forms a
ah ≡ 1 (mod n) ⇔ k | h where h is a complete residue system modulo 7.
positive integer.
3.22. (a) Show that 2p ≢ 2 (mod p2 )
[Hint: Use the Division Algorithm.] where p is an odd prime.
3.16. *Let a be even and p be prime such (b) Show the result is true for the
that gcd (a, p) = 1 but prime p = 1093, that is
a2 ≡ −1 (mod p) . 2p ≡ 2 (mod p2 ).
Show that [Hint: You may use the result
2364 ≡ 1(mod 10932 ).]
p ≡ 1 (mod 4) .
3.23. **Lagrange’s Theorem. Let P (x) be a
3.17. *Show that the last two digits of a polynomial with integer coefficients
perfect square must be one of the (see Introductory Chapter for
following: definition) given by
00, e1, e4, 25, o6, and e9 where o P(x) = cm xm + cm−1 xm−1 + ⋯ +
represents odd and e represents c1 x + c0
even. where cm ≢ 0 (mod p) and p is
3.18. (i) Find all the incongruent prime.
solutions of x2 ≡ 1 (mod 8). Prove that the polynomial
(ii) Find all the incongruent congruence
solutions of x2 ≡ 1 (mod 7). P (x) ≡ 0 (mod p)
3.19. Factorize 2 027 651 281. has at most m incongruent solutions.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
..............................................................................................................................
A Survey of Modular
4 Arithmetic with Prime
Moduli
..............................................................................................................................
In Example 4.3 later in this section we will find that applying Fermat’s Little Theorem greatly
simplifies this problem.
We will also use Fermat’s Little Theorem (FlT) to solve linear congruences with prime
moduli and to find the inverse of a ( mod p) where p is prime. Also, in this section we will
evaluate indices in modular arithmetic in a much easier way than in the previous chapter.
In this chapter we confine ourselves to a prime modulo, that is n = p. In the next chapter
we generalize the results of this chapter to modulo a composite n. An outline of this pro-
gression can be seen in Figure 4.1.
Figure 4.1
Additionally, in this chapter we use modular arithmetic to find factors of 2n − 1 and show
that if 2n − 1 is prime then it generates a perfect number.
First we develop a table of values and then we will state and prove an important result in-
volving a particular index with a prime modulo.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
154 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Example 4.1
Construct a table of values for the first five powers of each positive residue modulo 5.
Solution
We evaluate the powers of the least positive residues a = 1, 2, 3, and 4 modulo 5.
This gives:
a 1 2 3 4
2 2 2 2
a2 1 ≡ 1 (mod 5) 2 ≡ 4 (mod 5) 3 ≡ 4 (mod 5) 4 ≡ 1 (mod 5)
3 3 3 3
a3 1 ≡ 1 (mod 5) 2 ≡ 3 (mod 5) 3 ≡ 2 (mod 5) 4 ≡ 4 (mod 5)
4 4 4 4
a4 1 ≡ 1 (mod 5) 2 ≡ 1 (mod 5) 3 ≡ 1 (mod 5) 4 ≡ 1 (mod 5)
5 5 5 5
a5 1 ≡ 1 (mod 5) 2 ≡ 2 (mod 5) 3 ≡ 3 (mod 5) 4 ≡ 4 (mod 5)
14 ≡ 24 ≡ 34 ≡ 44 ≡ 1 ( mod 5) .
In general a4 ≡ 1 ( mod 5), provided that a is not divisible by 5.
This result is no coincidence, but will also work with other prime moduli. For example,
you will find the following results:
112 ≡ 212 ≡ 312 ≡ 412 ≡ 512 ≡ 612 ≡ 712 ≡ 812 ≡ 912 ≡ 1012 ≡ 1112 ≡ 1212 ≡ 1 ( mod 13) .
This only works with a prime modulo and is an example of a general proposition named
after the French mathematician Pierre de Fermat: Fermat’s Little Theorem—FlT. (We use
the lower case l to distinguish from Fermat’s Last Theorem, which is normally denoted FLT.)
IN T R O D U C T I O N TO F E RM AT ’ S L I TT L E T H E O R E M ( 1 5 3 – 1 6 2 ) 155
Fermat’s Last Theorem is more popular than his Little Theorem because it famously took
nearly 350 years to prove. Fermat’s Last Theorem states:
Fermat’s Little Theorem is a fundamental theorem in number theory and it is a result which
makes evaluating a power of a residue to a prime modulo much easier.
Fermat’s Little Theorem states that if p is prime and a is any integer such that p does not
divide a then
ap−1 ≡ 1 ( mod p) .
Here are some more numerical examples with moduli primes 7, 11, and 17:
Fermat’s Little Theorem (4.1). Let a be an integer and p be a prime number which does not
divide a. Then
ap−1 ≡ 1 ( mod p) .
This result implies p divides ap−1 − 1 because ap−1 − 1 ≡ 0 ( mod p). For example,
Proof.
We examine the first p − 1 positive multiples of a:
Each of these residues in the list (∗) are incongruent modulo p. This means that none of
these residues are congruent to each other modulo p.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
156 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Why?
Suppose there are two residues in the list (∗) which are congruent to each other:
a × 2a × 3a × ⋯ × (p − 1) a ≡ 1⏟⎵
×⎵
2⎵×⎵3⎵⎵⏟⎵
× ⋯⎵
×⎵(p
⎵⎵−⎵⏟
1) × ⏟⎵
a ×⎵
a⎵×⎵⏟⎵
a ×⎵
⋯ ×a
⎵⎵⏟
=(p−1)! p−1 copies
Since the numbers in the list (∗) are not congruent to each other, so every one of these
numbers is congruent to one of 1, 2, 3, 4, …, p − 1 in some order. This implies that we have
(p − 1)! × ap−1 ≡ 1 × 2 × 3 × 4 × ⋯ × (p − 1)
≡ (p − 1)!( mod p) .
Applying the above Cancellation Law (3.12) to ap−1 × (p − 1)! ≡ 1 × (p − 1)! ( mod p) with
c = (p − 1)! because p (p − 1)! gives
ap−1 ≡ 1( mod p) .
Why?
If we have a prime modulo then it is simpler to work with ap−1 ≡ 1 ( mod p) because
1k ≡ 1 ( mod p) for any natural number k. Having residue 1 ( mod p) makes evaluation of
powers a lot easier.
Example 4.2
IN T R O D U C T I O N TO F E RM AT ’ S L I TT L E T H E O R E M ( 1 5 3 – 1 6 2 ) 157
Solution
Since 11 is prime and 11 does not divide 7, so applying FlT:
ap−1 ≡ 1 ( mod p) ,
52 = (5 × 10) + 2.
Therefore,
752 ≡ 7(5×10)+2 ≡ 75×10 × 72 [Using am+n = am × an ]
5 n
≡ (710 ) × 72 [Using am×n = (am ) ]
(1) 5 × 49 ≡ 1 × 5 ≡ 5 ( mod 11) .
≡⏟
By (∗)
752 = 88 124 787 089 723 195 184 393 736 687 912 818 113 311 201
divided by 11 leaves remainder 5. Imagine evaluating 752 ( mod 11) without using FlT;
Example 4.3
Find the remainder when 3101 is divided by 31. (The number 3101 has 49 digits.)
Solution
Let r be the remainder such that
3101 ≡ r ( mod 31) .
Since 31 is prime and 31 does not divide 3, so we can apply FlT:
ap−1 ≡ 1 ( mod p) ,
Rewriting the given index 101 as a multiple of 30 and any remainder 101 = (30 × 3) + 11 in
3101 ≡ r ( mod 31) yields
3
3101 ≡ 3(30×3)+11 ≡ (330 ) × 311 [By using the rules of indices]
≡ 13 × 311 [By (‡)]
≡ 311 ( mod 31) .
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
158 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
We need to write 311 as the least non-negative residue modulo 31. Evaluating indices of 3 which
gives a small remainder is the following:
33 ≡ 27 ≡ −4 ( mod 31) .
Using this 33 ≡ −4 ( mod 31) to simplify the above result 3101 ≡ 311 ( mod 31) gives
3101 ≡ 311
3
≡ 3(3×3)+2 ≡ (33 ) × 32 ≡ (−4) 3
⏟ × 9 ≡ −64 × 9 ≡ −2 × 9 ≡ −18 ≡ 13 ( mod 31) .
By above
We have r ≡ 3101 ≡ 13 ( mod 31). The remainder after dividing 3101 by 31 is 13.
Example 4.4
Let p be prime and a be an integer such that prime p does not divide a. Show that ap−2 is the inverse
of a modulo p. (In notation form we have a−1 ≡ ap−2 ( mod p).)
Solution
What does inverse mean in this case?
By Definition (3.20) of the last chapter:
ax ≡ 1 ( mod n) ⇒ solution x is inverse of a ( mod n).
By FlT we have
We can use this result of Example 4.4 to find the inverse of a modulo p. For example,
determine 2−1 ( mod 31).
First the inverse of 2 modulo 31 exists because 2 and 31 are relatively prime.
From the previous Example 4.4, we have
Hence the inverse of 2 modulo 31 is 16, that is 2−1 ≡ 16 ( mod 31). Note that
2 × 16 ≡ 32 ≡ 1 ( mod 31) .
IN T R O D U C T I O N TO F E RM AT ’ S L I TT L E T H E O R E M ( 1 5 3 – 1 6 2 ) 159
Example 4.5
Solution
Since 31 and 37 are relatively prime, so 31x ≡ 5 ( mod 37) has a unique solution.
First, we find the inverse of 31 modulo 37.
Why?
Because 31 × 31−1 ≡ 1 ( mod 37). Multiplying both sides of our given equation by 31−1 ( mod 37)
gives
⏟
31⎵−1
⎵⏟× ⏟ x ≡ 31−1 × 5 ( mod 37) implies x ≡ 31−1 × 5 ( mod 37) .
⎵⎵31 (∗)
≡1( mod 37)
Since 37 is prime and does not divide 31, so by the result of Example 4.4 we have
35
31−1 ≡ 3137−2 ≡ 3135 ≡
⏟ (−6) ( mod 37) . (†)
Because 31≡−6( mod 37)
35
We need to find (−6) modulo 37. First, we evaluate a small power of −6 and then we apply the
rules of indices:
2
(−6) ≡ 36 ≡ −1 ( mod 37) implies
35 34 2 17 17
(−6) ≡ (−6) × (−6) ≡ ((−6) ) × (−6) ≡ (−1) × (−6) ≡ 6 ( mod 37) .
35
So, by (†) we have 31−1 ≡ (−6) ≡ 6 ( mod 37). Substituting this into (∗) gives
x ≡ 6 × 5 ≡ 30 ( mod 37) .
In Example 4.5 you may have noticed that solving 31x ≡ 5 ( mod 37) is easier than trying
to solve the Diophantine equation 31x = 5 + 37y, as we did in Chapter 3.
ap ≡ a ( mod p) .
In FlT the prime p did not divide integer a. This result also applies to the case when p
divides a.
Additionally, this ap ≡ a ( mod p) implies
160 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Proof.
Case I: Assume prime p does divide a, that is p | a, then
ap−1 ≡ 1 ( mod p) .
a × ap−1 ≡ (a × 1) ( mod p)
ap ≡ a ( mod p) .
The Chinese knew this result for a = 2 and an odd prime p, that is 2p ≡ 2 ( mod p). They
did not have the modular arithmetic notation, so they knew it as p | (2p − 2).
We can apply this corollary to show a result that seems obvious.
Example 4.6
Solution
How is this problem related to Fermat’s Little Theorem?
Well we can write two consecutive integers as a − 1 and a. Their product is
a (a − 1) = a2 − a.
From this result a (a − 1) ≡ 0 ( mod 2) , we have that 2 divides a (a − 1), or that the product of two
consecutive integers a − 1 and a is even.
Similarly, we can prove that the product of three consecutive integers is divisible by 3 (see
Exercises 4.1, question 14 (i)).
Additionally, FlT can be used for testing whether a given number is composite because
the contrapositive of FlT says:
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN T R O D U C T I O N TO F E RM AT ’ S L I TT L E T H E O R E M ( 1 5 3 – 1 6 2 ) 161
1001 = 7 × 11 × 13.
4.1.4 Pseudoprimes
This means we need to check that if an−1 ≡ 1 ( mod n) then n is prime. Let n = 561 and
a = 2 then by using a calculator or computer algebra system we find that
However, 561 = 3 × 11 × 17, therefore 561 is composite. The converse of FlT does not
hold;
an−1 ≡ 1 ( mod n) /⇒ n is prime.
We call numbers like 561 pseudoprimes—false primes. Another pseudoprime is 341
which is composite because 341 = 11 × 31. However,
There is a difference between the pseudoprimes 341 and 561. Examine the following
results for modulo 341:
Carmichael numbers are very rare, the smallest being 561. There are only 2163 Carm-
ichael numbers in the first 25 billion natural numbers.
However, in 1994 it was proved that there are infinitely many Carmichael numbers.1 The
existence of Carmichael numbers prevents FlT being used to test primality. We will revisit
pseudoprimes and Carmichael numbers in Section 4.4.
1
Alford, Granville, and Pomerance, ‘There are Infinitely Many Carmichael Numbers,’ Ann.
Math. 139, 703–22, 1994.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
162 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Summary
FlT (4.1). Let a be an integer and p be a prime number which does not divide a. Then
ap−1 ≡ 1 ( mod p) .
This is a fundamental theorem of number theory which is used to simplify powers of residues modulo
a prime.
EXERCISES 4.1
(Brief solutions at end of book. Full 6. Show that 22046 ≡ 1 ( mod 2047). Check
solutions available at <http://www.oup.co. whether 2047 is prime.
uk/companion/NumberTheory>.)
7. Show that
1. Determine the least non-negative 740 353 606 ≡ 0 ( mod 40 353 607).
residue x of the following congruences:
(a) 7101 ≡ x ( mod 11) Is 40 353 607 prime?
(b) 21976 ≡ x ( mod 13) 8. Given that
(c) 51961 ≡ x ( mod 7) 21 234 566 ≡ 899 557 ( mod 1 234 567), is
(d) 32013 ≡ x ( mod 23) the number 1 234 567 composite or
(e) 262013 ≡ x ( mod 23) prime?
2. Determine the multiplicative inverse
9. Find a solution of x101 ≡ 5 ( mod 13).
of the following numbers by using
Fermat’s Little Theorem. Give your 10. Prove the following:
answer as the least non-negative (a) 1p−1 + 2p−1 + 3p−1 + ⋯
p−1
residue. + (p − 1) ≡ −1 ( mod p)
(a) 5 ( mod 11) (b) 9 ( mod 23) where p is prime.
(c) 2 ( mod 37) (d) 5 ( mod 41) (b) 1p + 2p + 3p + ⋯
p
3. (i) Determine the remainder when + (p − 1) ≡ 0 ( mod p)
62014 is divided by 11. where p is an odd prime.
(ii) Determine the remainder when You may find the following result
62013 is divided by 11. helpful:
4. (i) Find 821 ( mod 23). n (n + 1)
1+2+3+⋯+n = .
(ii) Solve the equation 2
8x ≡ 7 ( mod 23). 11. (i) Let p be prime and p n. Prove that
5. (a) Show that 28190 ≡ 1 ( mod 8191). the solutions of nx ≡ a ( mod p) is
given by
What can you say about the number 8191? x ≡ np−2 a ( mod p) .
(b) Show that 265 536 ≡ 1( mod 65 537).
(ii) Solve the linear congruence
What can you say about the number 65 537? 10x ≡ 11 ( mod 17).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
.........................................................................................................
Like Fermat’s Little Theorem, for Wilson’s Theorem we confine ourselves to a prime mod-
ulo. Wilson’s Theorem is valid both ways, that is the result is true going forwards ⇒ (suffi-
cient) and backwards ⇐ (necessary). This is not the case for Fermat’s Little Theorem, as we
observed in Subsection 4.1.4.
John Wilson (1741–93) attended the University of Cambridge, becoming Senior Wran-
gler, which means he achieved the highest marks on taking the Mathematical Tripos ex-
amination. However, John Wilson rediscovered Wilson’s Theorem, because it was known
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
164 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
700 years earlier by Ibn al-Haytham (965–1040 AD) who made major contributions to
mathematics (particularly geometry and number theory), optics (being the first to claim
that we see objects when light is reflected off an object into the eye), and astronomy. He is
also considered to be one of the first theoretical physicists.
Ibn al-Haytham was born in the Iraqi city of Basra but spent his adult life in Cairo, Egypt.
He dedicated his life to mathematics and physics after giving up on religion.2
Example 4.7
Solution
x ≡ 4! ≡ −1 ( mod 5) .
x ≡ 6! ≡ 720 ≡ 6 ≡ −1 ( mod 7) .
These evaluations were nice and easy, but evaluating n! for a large n will not be so simple.
We want to find a simpler way of evaluating this n! modulo a prime.
We can be smart about this by using the inverse of a residue, as described in Example 4.8
below. The proof of Wilson’s Theorem relies on the inverse in modular arithmetic.
Example 4.8
Determine the least non-negative residue x ( mod 13) in the following congruence:
Solution
Remember what factorial ! means:
2
https://mathshistory.st-andrews.ac.uk/Biogrpahies/Al-Haytham
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
If we multiply the first and last numbers on the right-hand side of (∗) we have
1 × 12 ≡ 12 ≡ −1 ( mod 13) .
We can carry out some simplification on the remaining numbers 2, 3, . . . , 11 in the product on the
right-hand side.
We are dealing with a prime modulo, 13. If a = 2, 3, 4, . . . , 11 then gcd (a, 13) = 1, which implies
that each of these a’s will have an inverse because a and 13 are relatively prime. For example,
2 × 7 ≡ 14 ≡ 1 ( mod 13) .
Therefore, the inverse of 2 is 7 modulo 13. Similarly, we can pair up all the remaining numbers:
3 × 9 ≡ 27 ≡ 1 ( mod 13)
4 × 10 ≡ 40 ≡ 1 ( mod 13)
5 × 8 ≡ 40 ≡ 1 ( mod 13)
6 × 11 ≡ 66 ≡ 1 ( mod 13) .
We use these concepts of pairing residues with their inverse in the derivation of Wilson’s
Theorem. However, before we can derive the theorem we need one more result, namely this
lemma:
Proof.
How do we prove this result?
a2 ≡ b2 ( mod p) ⇔ a ≡ ±b ( mod p)
with a = x and b = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
166 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
The consequence of Lemma (4.3) may not seem quite so obvious at first glance. However,
if we take a closer look at the two values of x which satisfy x2 ≡ 1 ( mod p) we can extract a
useful result.
This means that the values of x which satisfy x2 ≡ 1 ( mod p) are x ≡ 1 ( mod p) or
x ≡ −1 ≡ p − 1 ( mod p). Furthermore, each of these values for x is its own self-inverse—a
property we’ll use in our proof of Wilson’s Theorem.
In the previous Example 4.8 the congruence x ≡ ±1 ( mod p) of Lemma (4.3) corre-
sponds to
x ≡ 1 ( mod 13) and x ≡ −1 ≡ 12 ( mod 13) .
The modular inverse of 12 ( mod 13) is 12 ( mod 13) because
First, we establish the result for the first two primes, p = 2 and p = 3, then we prove the
result for the remaining primes.
Proof.
Let p = 2 or p = 3 then
1, 2, 3, 4, … , p − 1.
By the previous Lemma (4.3) we know that the first and last numbers in this list, 1 and
p − 1, are their own inverses. Removing these two values from our list, we get the reduced
list of 2, 3, 4, …, p − 2.
The inverse of these remaining residues 2, 3, 4, …, p − 2 is another number in this list.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Why?
ax ≡ 1 ( mod p) where a = 2, 3, 4, ⋯ , p − 2.
Why not?
2, 3, 4, ⋯ , p − 2
×⎵
2⏟⎵3⎵×⎵4⎵⎵⏟⎵
× ⋯⎵
×⎵(p 2) ≡ 1 × 1 × 1 × ⋯ × 1 ≡ 1 ( mod p)
⎵⎵−⎵⏟
=(p−2)!
(p − 2)! ≡ 1 ( mod p) .
Therefore, we have:
(p − 1)! ≡ (p − 1) ⏟ −⎵
(p⎵⏟ ⏟ ( mod p)
2)!
≡1 by above
≡ (p − 1) ≡ −1 ( mod p) .
Example 4.9
Solution
168 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
x ≡ 11! ≡ 2 × ×4
3⏟ ×5 × 6 × 7 × 8 × 9 × 10 × 11
=12 ≡ 0 (mod 12)
≡ 2 × 0 × 5 × ⋯ × 11 ≡ 0 ( mod 12) .
(c) 13 is prime but we need to find 10! not 12!. By Wilson’s Theorem we have
If we multiply the last line 2 × 10! ≡ −1 ( mod 13) by the inverse of 2 ( mod 13) then we can find
x ≡ 10! ( mod 13).
What is the inverse of 2 ( mod 13) ?
By inspection we find 7 ( mod 13) because 2 × 7 ≡ 14 ≡ 1 ( mod 13). Multiplying both sides of (∗∗) by
7 gives:
× 7 ×10! ≡ 7 × (−1) ≡ −7 ≡ 6 ( mod 13) .
2⏟
≡1
You are asked to prove Wilson’s Theorem again in the exercises by using FlT—Exercises
4.2, question 17.
You can also use Wilson’s Theorem to prove that the quadratic congruence
x2 ≡ − 1 ( mod p) has a solution ⇔ p = 2 or p ≡ 1 ( mod 4) (see Exercises 4.2, question 16).
(We examine quadratic residues in Chapter 7.)
Proof.
Suppose n is composite. This means that n has at least two non-trivial factors (defined in
(3.25) of the last chapter):
d1 × d2 = n where d1 > 1 and d2 > 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
(n − 1)! = 1 × 2 × ⋯ × d1 × ⋯ × d2 × ⋯ × (n − 1)
= d1 × d2 × 1 × 2 × ⋯ × (n − 1) .
We have
(n − 1)! ≡ d⎵
⏟ ×⎵d⏟
1⏟ 2 ×1 × 2 × ⋯ × (n − 1) ( mod n)
≡0 (mod n) Because d1 ×d2 =n
≡ 0 × 1 × 2 × ⋯ × (n − 1) ≡ 0 ( mod n) .
Why?
It can be used to test for prime numbers because if (n − 1)! ≡ −1 ( mod n) then we conclude
that n is prime. However, this is not very practical.
Why not?
(n − 1)! becomes very large even for small values of n. There are more efficient ways of
testing whether numbers are prime or composite, which we will discuss in the next few
sections.
Generalizing factorial results for modular arithmetic we have:
Summary
Wilson’s Theorem:
(n − 1)! ≡ −1 ( mod n) ⇔ n is prime.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
170 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
EXERCISES 4.2
(Brief solutions at end of book. Full 9. Find the least non-negative residue
2
solutions available at <http://www.oup.co. (29 − 1)
[( )!] ( mod 29).
uk/companion/NumberTheory>.) 2
1. Determine the least non-negative 10. Prove the following:
residue x of the following congruences: (n − 1)!
p+1
What do you notice about your results? ≡ (−1) 2 ( mod p) .
.........................................................................................................
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
COM P O S I T E I N T E G E R S A ND P S E U D O P R I M E S ( FA L S E P R I M E S ) ( 1 7 1 – 1 8 1 ) 171
There is no easy way to find out whether a given odd integer is prime or composite.
How do we test whether 218 − 1 = 262 143 is composite or prime? If it is composite then what is the
prime factorization of this number?
2n−1 ≢ 1 ( mod n)
Proof.
By Fermat’s Little Theorem (4.1):
If n is prime which does not divide a, then an−1 ≡ 1 ( mod n).
The contrapositive is:
If an−1 ≢ 1 ( mod n) where n a then n is composite.
We substitute a = 2 to arrive at our result:
2n−1 ≢ 1 ( mod n) implies the odd integer n is composite.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
172 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Example 4.10
Solution
How do we test whether 511 is composite or not?
Using the previous Proposition (4.6) with n = 511 gives
We stop at 29 ≡ 1 ( mod 511) because this is a useful result to have, as 1 to any integer index is just
1. Remember we want to find 2510 ≡ x ( mod 511). Writing the index 510 as a multiple of 9 and any
remainder we have by the Division Algorithm
510 = (56 × 9) + 6.
Using the above result 29 ≡ 1 ( mod 511) and the rules of indices we have
56
2510 ≡ 2(56×9)+6 ≡ (29 ) × 26 ≡ 156 × 64 ≡ 64 ( mod 511) .
Note that the above proposition does not give us the factors of 511 but just tells us that
this number 511 is composite.
The general contrapositive statement of FlT is given by
In the above case we chose a to equal 2, but we could let a be any integer provided n a.
Therefore, the general proposition is:
Proof.
This is the contrapositive statement of FlT.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
COM P O S I T E I N T E G E R S A ND P S E U D O P R I M E S ( FA L S E P R I M E S ) ( 1 7 1 – 1 8 1 ) 173
Why use this result an−1 ≢ 1 ( mod n) rather than the previous 2n−1 ≢ 1 ( mod n) ?
For some numerical examples we may have 2n−1 ≡ 1 ( mod n) but, as discussed in Section
4.1, this does not imply that n is prime (pseudoprime). To deduce that n is composite we
need to show for some other base, a say, such that an−1 ≢ 1 ( mod n).
Additionally, it can be easier to work with another base rather than 2. Plus, it is always
useful to not be constrained to a particular base.
Example 4.11
Solution
If we use base 2 we find by using a calculator ( justify in your own time) that
This is not a very efficient way of testing for composite integers, since it requires us to have
some way of knowing beforehand what base is most suited, something which isn’t always
obvious.
Example 4.12
Determine the least positive residue x such that 2340 ≡ x ( mod 341).
Solution
Evaluating various powers of 2 we have
Using the last result 210 ≡ 1 ( mod 341) and by the rules of indices we get
34
2340 ≡ (210 ) ≡ 134 ≡ 1 ( mod 341) .
174 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
This result 2340 ≡ 1 ( mod 341) does not imply that 341 is prime. In fact, 341 is composite
because
341 = 11 × 31.
For over 2500 years the mathematical community did think that if 2n−1 ≡ 1 ( mod n)
then n was prime. (Actually this modular arithmetic was not developed until the 19th
century, so for over 2000 years people wrongly thought that if n | (2n−1 − 1) then n is
prime.)
In 1819, the above example 2340 ≡ 1 ( mod 341) was discovered and it was found that 341
is a composite integer.3 This 341 is an example of a pseudoprime.
We define pseudoprime formally as:
Definition (4.8). A composite integer n is called a base a-pseudoprime (or just a pseudo-
prime) if
an−1 ≡ 1 ( mod n) where gcd (a, n) = 1 and a > 1.
For example, 341 is a base 2-pseudoprime because 2340 ≡ 1 ( mod 341). This 341 is the
smallest base 2-pseudoprime.
Example 4.13
Solution
First gcd (3, 91) = 1. For 91 to be a base 3-pseudoprime we need to show two things:
I) 91 is composite and II) 390 ≡ 1 ( mod 91).
Showing each of these:
I) 91 = 7 × 13 so 91 is composite.
II) Evaluating powers of 3 we have
Using this last result 36 ≡ 1 ( mod 91) to evaluate 390 ≡ ? ( mod 91) we have
15
390 ≡
⏟ 36×15 ≡
⏟ (36 ) ≡ 115 ≡ 1 ( mod 91) .
because 90=6×15 by the rules of indices
Since 390 ≡ 1 ( mod 91), so 91 is a base 3-pseudoprime. (You are asked to show in Exercises 4.3, ques-
tion 3 (b) that 91 is not a base 2-pseudoprime.)
91 is the smallest base 3-pseudoprime. The numbers 217 and 25 are pseudoprimes of
bases 5 and 7 respectively and these are the smallest base 5- and 7-pseudoprimes (see
Exercises 4.3, question 18).
3
https://primes.utm.edu/curios/page.php/341.html.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
COM P O S I T E I N T E G E R S A ND P S E U D O P R I M E S ( FA L S E P R I M E S ) ( 1 7 1 – 1 8 1 ) 175
Proposition (4.9). If m | n then (2m − 1) | (2n − 1) where m and n are positive integers.
Proof.
We are given that m | n, so there is an integer k such that
m × k = n.
Substituting a = 2 we have
(27 − 1) | (214 − 1) .
Example 4.14
Solution
The non-trivial factors (we defined non-trivial factors in the last chapter (3.25)) of the index 18 are 2,
3, 6, and 9. We use Proposition (4.9):
If m | n then (2m − 1) | (2n − 1).
176 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Hence some of the factors of 218 − 1 are 3, 7, 63, and 511. Note that Proposition (4.9) does not say all
the factors of 2n − 1 are of the form 2m − 1 where m | n .
The largest factor in this list is 511 and dividing by this number gives
218 − 1
= 513 or 218 − 1 = 511 × 513. (∗)
511
By using the test for divisibility by 9 we have that adding the digits of 513 gives 5 + 1 + 3 = 9 and 9 | 9,
therefore 9 is a factor of 513:
513
= 57 or 513 = 9 × 57 = 32 × 57 = 32 × 3 × 19 = 33 × 19.
9
The factors of 511 are 7 × 73 = 511. Substituting these into (∗) yields
Example 4.15
Solution
Clearly 7 | 777, so by Proposition (4.9) we have that 27 − 1 = 127 is a factor of 2777 − 1. Hence 2777 − 1
is composite.
Proof.
See Exercises 4.3, question 15.
Proof.
See Exercises 4.3, question 10.
Take care to notice that this corollary does not imply that if n is prime then 2n − 1 is also
prime. For example, take n = 11 which is prime but 211 − 1 = 2047 = 23 × 89 is composite.
COM P O S I T E I N T E G E R S A ND P S E U D O P R I M E S ( FA L S E P R I M E S ) ( 1 7 1 – 1 8 1 ) 177
The next result tells us how we can generate a new pseudoprime from a given pseudoprime.
Proof.
We need to prove two things:
I) 2341 − 1 is composite.
341 −2
II) 22 ≡ 1 ( mod 2341 − 1).
Proof of I).
Factorizing 341 gives 341 = 11 × 31, so 341 is composite. By the previous Corollary (4.11):
if n is composite then 2n − 1 is also composite,
we have that 2341 − 1 is composite.
Proof of II).
341
We need to show 22 −2 ≡ 1 ( mod 2341 − 1). From Example 4.12, we know that 341
is a base 2-pseudoprime, therefore 2340 ≡ 1 ( mod 341). Multiplying both sides of this
2340 ≡ 1 ( mod 341) by 2 gives
2 × 2340 ≡
⏟ 2341 ≡ 2 ( mod 341) .
By rules of indices
341 −2
22 ≡ 2341k ( mod 2341 − 1) . (†)
178 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
341
We have shown 22 −2 ≡ 1 ( mod 2341 − 1).
As we have proved both parts I) and II), so 2341 − 1 is a base 2-pseudoprime.
This proposition says that if we have the base 2-pseudoprime 341 then by using this we
can produce another base 2-pseudoprime, 2341 − 1. This is not only true of 341, but is also
true for other pseudoprimes n.
Proof.
Exercises 4.3, question 11.
This leads us to say there are infinitely many base 2-pseudoprimes. You will be asked to
show this in Exercises 4.3, question 20.
A natural question to ask is:
Yes, and you are asked to show this in Supplementary Problems 4, question 29.
From Example 4.12 we have that 341 is a base 2-pseudoprime. If we use base 3 then we get
the following:
3340 ≡ 56 ( mod 341) .
But 561 is a composite number because 561 = 3 × 11 × 17. Such a number is called a
Carmichael number. This means that every a which is not a multiple of 3, 11, or 17 or a
combination of these will give a560 ≡ 1 ( mod 561).
However, the index 560 to base 3, 11, and 17 will not give 1 modulo 561:
COM P O S I T E I N T E G E R S A ND P S E U D O P R I M E S ( FA L S E P R I M E S ) ( 1 7 1 – 1 8 1 ) 179
Definition (4.14). A composite integer n is called a Carmichael number if for every base
a we have
an−1 ≡ 1 ( mod n) provided gcd (a, n) = 1.
Other Carmichael numbers are 1105, 1729, 2465, … Actually there are infinitely many
Carmichael numbers, as stated in Section 4.1.
Example 4.16
Solution
How do we show this result?
561 = 3 × 11 × 17 is a composite integer. We also need to show that
a560 ≡ 1 ( mod 561) for every a such that gcd (a, 561) = 1.
We use FlT and the Chinese remainder theorem to show this. (continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
180 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Proof.
First using FlT (4.1):
ap−1 ≡ 1 ( mod p) where p a
with moduli p = 3, 11, and 17 because 561 = 3 × 11 × 17 we have:
However we don’t need these indices because we want to show a560 ≡ 1 ( mod 561), so we are interested
in the index 560. Using the rules of indices and the above results we have
280
a560 ≡ (a2 ) ≡ 1280 ≡ 1 ( mod 3) .
Similarly, by using the rules of indices in the bottom two congruences we have
56
a560 ≡ (a10 ) ≡ 156 ≡ 1 ( mod 11)
35
a560 ≡ (a16 ) ≡ 135 ≡ 1 ( mod 17) .
Let x = a560 , and putting this into the above computed congruences we have the simultaneous congruence
equations:
x ≡ 1 ( mod 3)
x ≡ 1 ( mod 11)
x ≡ 1 ( mod 17) .
x ≡ M ( mod p1 × p2 × p3 × ⋯ × pk ) .
Summary
We can use an−1 ≢ 1 ( mod n) to show that n is a composite number.
Pseudoprimes are composite integers n which satisfy FlT:
COM P O S I T E I N T E G E R S A ND P S E U D O P R I M E S ( FA L S E P R I M E S ) ( 1 7 1 – 1 8 1 ) 181
EXERCISES 4.3
.........................................................................................................
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
182 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
How would you find a factor of 2251 − 1 where the index 251 is prime?
Why?
Because the largest known primes are generally found amongst Mersenne primes, which
we define in this section. First we formulate a method to find a prime factor of a composite
Mersenne number such as 2251 − 1 in Example 4.20.
Mn = 2n − 1.
We discussed Mersenne numbers in the last section without naming them. We proved
the following property of these numbers:
2n − 1 is prime ⇒ n is prime.
Why not?
Because it is inefficient. We have if the larger integer 2n − 1 is prime then the smaller integer
n is prime, which means we have to first check 2n − 1 and then deduce that n is prime. For
example, we first need to check that 219 − 1 = 524 287 is prime and then conclude that the
index 19 is prime. It is much easier to test the smaller number 19 rather than 524 287.
22 − 1 = 3, 23 − 1 = 7, 25 − 1 = 31, ⋯ .
Mersenne listed the following 11 primes p for which he claimed that 2p − 1 was prime:
His list had two incorrect primes because M67 = 267 − 1 and M257 = 2257 − 1 are composite.
Testing whether Mersenne numbers are prime has been an ongoing problem for nearly
400 years. Of course, the greatest strides have been made since the advent of the digital
computer. Prior to computer technology, the American mathematician Frank Cole (1861–
1926) found the following factorization in October 1903:
M67 = 267 − 1 = 147 573 952 589 676 412 927 = (761 838 257 287) × (193 707 721) .
Legend has it that Cole spent three years of Sunday afternoons trying to find these factors.
Frank Cole gave this factorization at a meeting of the American Mathematical Society
with the title ‘On the Factorization of Large Numbers’. He did not speak a single word,
but just showed the above factorization on the board. It was one of the strangest talks ever
given.4 Hence Cole showed that the Mersenne list of primes given in the list (†) was incorrect
because M67 = 267 − 1 is composite.
Also Mersenne missed three primes, 61, 89, and 107, from his list. All of these
Mp = 2p − 1 are prime for p = 61, 89 and 107.
4
Number Theory: A Historical Approach by John Watkins, page 135.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
184 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Listing Mersenne numbers for the first few prime numbers p, we have:
Table 4.2
p 2 3 5 7 11 13
p
2 −1 3 7 31 127 2047 = 23 × 89 8191
Recall from the last section that if p is prime then there is no guarantee that 2p − 1 is
prime, as you can observe for p = 11. Remember from the last section:
⇒ 2p − 1 is prime.
p is prime /
It is also claimed that there are infinitely many Mersenne primes. However, this is still a
conjecture as no one has been able to prove this so far.
Since 1996 there has been a computer programme called Great Internet Mersenne Prime
Search, abbreviated to GIMPS, which was started by George Woltman to find primes.
We want to find a prime factor of a given composite Mersenne number Mn without using
the brute force technique of testing all the primes up to the square root of Mn .
The following is one such test:
Proposition (4.18). Let n be a natural number and p = 2n + 1 be an odd prime, then either
p | (2n − 1) or p | (2n + 1) but not both.
2n − 1 = 22 − 1 = 3 and 2n + 1 = 22 + 1 = 5.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
By the given proposition, p = 31 divides only one of these numbers: 32 767 or 32 769.
32 767
Checking this with a calculator gives = 1057. So 31 | (215 − 1).
31
Proof.
We need to prove p | (2n − 1) or p | (2n + 1), which in terms of congruence means we are
required to show that
We are given p = 2n + 1, which implies p − 1 = 2n. Substituting this p − 1 = 2n into (‡) and
applying the rules of indices gives
2
2p−1 ≡ 22n ≡ (2n ) ≡ 1 ( mod p) .
2
We have (2n ) ≡ 1 ( mod p). Applying Lemma (4.3):
x2 ≡ 1 ( mod p) ⇔ x ≡ ±1 ( mod p) .
Then
p | [(2n + 1) − (2n − 1)] implies p | 2.
This p | 2 is impossible because we are given p = 2n + 1, which means p is an odd prime.
Hence p cannot divide both p | (2n − 1) and p | (2n + 1). This completes our proof.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
186 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Example 4.17
Solution
Let n = 23 then p = (2 × 23) + 1 = 47 which is prime. By applying the previous result:
p | (2n − 1) or p | (2n + 1) where p = 2n + 1,
we have 47 | (223 − 1) or 47 | (223 + 1). By using our calculator on the first of these we find
223 − 1 = 47 × 178 481.
Hence a prime factor of 223 − 1 is 47. (The other number, 178 481, is also a prime.)
M23 is composite with prime factors 47 and 178 481. Not always will we get a pair of
prime factors when we perform such division.
In this example we found that 47 divides 223 − 1, which implies that 47 does not divide
23
2 + 1.
Our aim in this section is to find a prime factor of the composite Mersenne number
Mn = 2n − 1. A natural question is:
The next proposition gives us the form of primes for which we can conclude that p = 2n + 1
is a prime factor of 2n − 1 or 2n + 1.
p = 47 = (2 × 23) + 1 ≡ 47 ≡ 7 ≡ −1 ( mod 8) .
Now n = 23, so applying result (a), p | (2n − 1), with p = 47 and n = 23 gives
47 | (223 − 1) .
Note that we do not need to use our calculator to determine a prime factor of 223 − 1.
To determine whether the prime p = 2n + 1 is a factor of 2n − 1 we need to check the
prime p leaves remainder 1 or 7 after dividing by 8.
Proof.
See Exercises 7.3, question 13 because we need to use quadratic residues.
Example 4.18
Solution
In this case let n = 50, then 2n + 1 = (2 × 50) + 1 = 101 which is prime. Let p = 101 then
p = 101 ≡ 5 ≡ −3 ( mod 8) .
Notice how useful this proposition is, because it tells us that 101 is a prime factor of
By writing out the decimal digits of 250 + 1 we can see that 5 is also a factor of this.
We will show in Exercises 4.4, question 15 that 2n + 1 is composite provided n is not a
power of 2. Hence 2n + 1 is composite for all n apart from when index n = 2m . This is why
we look for primes amongst 2n − 1, rather than 2n + 1.
Without Proposition (4.19), finding prime factors of composite numbers like 2n ± 1 is a
very tiresome task, even for small n.
Example 4.19
Find a prime factor greater than 3 of 2116 − 1 [3 is a factor because (22 − 1) | (2116 − 1)].
Solution
Let the index n = 116, then 2n + 1 = (2 × 116) + 1 = 233. We have to check that 233 is prime, other-
wise we cannot use the previous proposition.
How do we test 233 is prime?
By using Corollary (2.10) of Chapter 2:
⌊√233⌋ = 15.
188 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
2116 − 1 = 83 076 749 736 557 242 056 487 941 267 521 535.
Without this Proposition (4.19) it would be very time-consuming to find this prime factor,
233, of 2116 − 1. [Once this number is written in decimal digits we can see that 5 is also a
factor of 2116 − 1.]
Be careful when applying Proposition (4.19), as demonstrated by the following:
Locate the first error in the following derivation:
Step 1: Let n = 44 then 2n + 1 = (2 × 44) + 1 = 89 and 89 is prime.
Step 2: We have 89 ≡ 1 ( mod 8) .
Step 3: Therefore, 44 | (289 − 1).
There is definitely an error because 289 − 1 is an odd number and 44 is even, so
44 (289 − 1). Actually 289 − 1 is a Mersenne prime, so it has no factors apart from 1 and
itself. The error occurs in the last line (Step 3) because we should have
Definition (4.20). If q and p = 2q + 1 are both primes, then we say that q is a Germain prime.
For example, we say that 2 is a Germain prime because 2 is prime and
(2 × 2) + 1 = 5 is also prime.
(2 × 23) + 1 = 47 is prime.
(2 × 47) + 1 = 95 is composite.
Germain primes are named after the great French mathematician Sophie Germain.
{Digression: Sophie Germain proved that if there are non-zero integer solutions to
x5 + y5 = z5 (this is the special case of Fermat’s Last Theorem for n = 5) then one of the
integers (x, y, or z) must be divisible by 5.}
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Recall if the index n is prime then this does not guarantee that the Mersenne number
2n − 1 is prime. In this subsection we find a prime factor of composite Mersenne numbers
2q − 1 where the q is confined to a prime index. [We dealt with composite index in the last
section.]
Corollary (4.21). Let q and p = 2q + 1 both be primes. Note that q is a Germain prime.
(a) If q ≡ −1 ( mod 4) then p | (2q − 1).
(b) If q ≡ 1 ( mod 4) then p | (2q + 1).
Proof.
(a) We prove this by applying Proposition (4.19) (a):
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
190 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
p = 2q + 1 = 2 (4k − 1) + 1
= 8k − 2 + 1 = 8k − 1 ≡ −1 ( mod 8) .
p | (2q − 1) .
Example 4.20
Find a prime factor of composite M251 = 2251 − 1. (The index 251 is prime.)
Solution
Let q = 251 and p = 2q + 1, then p = (2 × 251) + 1 = 503. You can check that 503 is prime. Thus both
q = 251 and p = 503 are primes. Therefore, 251 is a Germain prime.
Also we have
q = 251 ≡ 3 ≡ −1 ( mod 4) .
Applying the previous Corollary (4.21) (a):
if q ≡ −1 ( mod 4) then p | (2q − 1),
503 | (2251 − 1) .
M251 = 2251 − 1 has 76 digits and Example 4.20 has found a prime factor, 503, of this
76-digit number.
You should be able to recognize how effective the above corollary is in finding a prime
factor of composite Mersenne numbers.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
If we were not given that M251 is composite, how would we know it is composite?
Proof.
See Exercises 4.4, question 10.
Since 11 and 251 are Germain primes, so the Mersenne numbers M11 = 211 − 1 and
M251 = 2251 − 1 are both composite numbers. Another example is the following.
Let q = 83 ≡ 3 ≡ −1 ( mod 4) and p = 2 (83) + 1 = 167. You can check that both 83 and
167 are prime, which implies that 83 is a Germain prime. By Corollary (4.21)(a) p | (2q − 1)
we have 167 | (283 − 1). Hence M83 = 283 − 1 is a composite number and a prime factor of
this number is 167.
Let us add another technique which simplifies finding prime factors of composite
Mersenne numbers.
Proposition (4.23). Let q be an odd prime. Any prime factor p of the composite Mersenne
number Mq = 2q − 1 is of the form p = 2kq + 1 where k is an integer.
Proof.
Exercises 4.4, question 18.
We can write each of these prime factors, 233, 1103, and 2089, as
2kq + 1 = (2 × 29 × k) + 1 = 58k + 1.
We have
All the prime factors of M29 = 229 − 1 are of the form 58k + 1. Therefore, to factorize
29
2 − 1 we don’t need to go through all the primes 2, 3, 5, …, but only those of the form
58k + 1 or p ≡ 1 ( mod 58).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
192 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
How do we know there are primes in this sequence of numbers of the form 58k + 1?
Proposition (4.24). Let q be an odd prime. Any prime factor p of Mq = 2q − 1 is of the form
p ≡ ±1 ( mod 8) .
Proof.
See Exercises 7.3, question 14.
Note that in the above M29 = 229 − 1 we have the prime factors satisfying
Example 4.21
Solution
Let p be a prime factor of M37 = 237 − 1 with index q = 37. Note that 37 is prime. By Proposition (4.23)
the prime factor p must be of the form
Writing out the list of numbers p = 74k + 1 for various k and checking that p is prime and satisfies
p ≡ ±1 ( mod 8) we have
This prime p = 149 must also satisfy p ≡ ±1 ( mod 8). Checking p = 149 ≡ 5 ( mod 8). This p cannot
be a prime factor of M37 because p ≡ 5 ≢ ±1 ( mod 8).
Substituting the next k = 3 into p = 74k + 1 gives
In a letter to Father Mersenne dated June 1640, Fermat informed him of how he had
factorized this number M37 = 237 − 1. Fermat did not go through all the primes 2, 3, 5, …
but only those which were of the form p = 74k + 1 = 149, 223, ⋯ to factorize this Mersenne
number.
As a closing note, let us state that much like Mersenne primes, the question as to whether
or not there are infinitely many Germain primes remains unanswered.
The largest known Germain prime p as of March 2016 is
Note: Germain primes and the largest Germain prime known then are mentioned in the
2005 film Proof.
Summary
A Mersenne number Mn is given by Mn = 2n − 1. In this section we have factorized composite
Mersenne numbers. We have the following factorization of Mn :
p ≡ ± 1(mod 8) p | (Mn = 2n – 1)
p = 2n + 1
p ≡ ± 3(mod 8) p | (2n + 1)
EXERCISES 4.4
194 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
6. Show that the following are prime: (ii) Show that 2239 − 1 is a composite
Mersenne number. Find a prime
(a) M13 = 213 − 1 (b) M17 = 217 − 1
factor of 2239 − 1.
7. Determine the first error in the
(iii) Find another prime factor of
following derivation and give reasons
2239 − 1.
for your answer:
13. Find a prime factor of
Step A: A prime factor q of 2193 − 1 is
of the form M1559 = 21559 − 1
where the index 1559 is prime.
q = (2 × 193 × k) + 1 = 386k + 1.
14. *Locate the first error in the following
Step B: Substituting k = 1 into this derivation and give reasons for your
q = 386k + 1 gives q = 387 which is answer:
composite.
Step A: A prime factor p of 261 − 1 is of
Step C: Substituting k = 2 into this the form
q = 386k + 1 gives q = 773 which is
p = 122k + 1.
prime.
Step D: Therefore, 773 is a prime factor Step B: With k = 1 we have p = 123
of 2193 − 1. which is composite.
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 195
.........................................................................................................
A fruitful source of primes is the Mersenne primes. By the late 1970s only 27 Mersenne
primes were known, but by the end of 2017 we knew of 50. The largest prime as of January
2019 is the Mersenne prime Mp :
M82 589 933 = 282 589 933 − 1 (The index 82 589 933 is prime).
This M82 589 933 = 282 589 933 − 1 has over 24 million digits.
This prime was found using the GIMPS described in the last section.
In essence it uses what we call the Lucas–Lehmer test which we state below:
This test is part of computational number theory, which is a growing area of number the-
ory. You are asked to apply this test to 213 − 1, see Exercises 4.5, question 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
196 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
The Electronic Frontier Foundation is offering the following rewards for finding large
prime numbers:
● $150 000 to the first individual or group that discovers a prime number with at least
100 million decimal digits
● $250 000 to the first individual or group that discovers a prime number with at least
a billion decimal digits.
In this section we will use the Mersenne primes to construct (even) perfect numbers.
We will show that perfect numbers are closely related to Mersenne primes.
Perfect numbers have been known for over 2000 years. However, after the ancient Greeks,
perfect numbers were forgotten about until the 1500s when Cataldi, Fermat, Descartes, and
Mersenne studied them.
Before we define perfect numbers we need to define proper factors or proper divisors:
Definition (4.26). A proper factor of a number n is any positive factor of n apart from n
itself.
For example, the proper factors of 12 are 1, 2, 3, 4, and 6 but not 12.
1 + 2 + 3 = 6.
1, 2, 4, 7, and 14.
Again if we add all the proper factors of 28 we get
1 + 2 + 4 + 7 + 14 = 28.
What do you notice about the sum of proper factors in these last two examples?
The sum of all the proper factors of 6 and 28 gives 6 and 28 respectively.
Such numbers, 6 and 28, are examples of perfect numbers.
Definition (4.27). A natural number n is called a perfect number if the sum of all its proper
factors (divisors) of n is equal to n.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 197
d1 + d2 + d3 + ⋯ + dk = n
Another example of a perfect number is 496 because the proper factors of 496 are
The Greeks made analogies of abundant numbers, with animals having more than five
fingers on one hand.
A number like 10 is an example of a deficient number because its proper factors 1, 2, and
5 sum to less than 10:
1 + 2 + 5 = 8 and 8 < 10.
Again the Greeks viewed deficient numbers as representing animals having less than five
fingers on one hand.5
Let d1 , d2 , ⋯ , dk be proper divisors of n. Then:
If d1 + d2 + ⋯ + dk > n then n is an abundant number.
If d1 + d2 + ⋯ + dk < n then n is a deficient number.
Therefore, 6, whose proper factors sum to exactly 6, is called a perfect number. The
Greeks also thought a perfect union of sexes was 6 = 2 × 3: 2 for female and 3 for male. A
natural set of questions to ask is:
How can we locate these perfect numbers? Is there a formula we can use to generate these or do we
have to check each number by adding its proper factors?
Yes, there is a formula to find even perfect numbers, which we describe next.
The Greek mathematician Euclid (300 BC) stated and proved the following result:
Theorem (4.28). Let p be a prime number. If the Mersenne number 2p − 1 is prime then
N = 2p−1 ⏟
(2⎵p⏟
−⎵⏟
1) is a perfect number.
prime
5
http://www-history.mcs.st-and.ac.uk/HistTopics/Perfect_numbers.html.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
198 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Before attempting a proof, let us look at the first few perfect numbers N:
The first four perfect numbers in this list were known to the ancient Greeks, but the fifth
perfect number 213−1 (213 − 1) = 33 550 336 was not discovered until the 1500s.
In the given formula N = 2p−1 (2p − 1) we must have that 2p − 1 is prime. Note that there
are large gaps between consecutive perfect numbers:
Peter Barlow in his book An Elementary Investigation of the Theory of Numbers, published
in 1811, claimed the following about the perfect number 230 (231 − 1):
230 (231 − 1) is the greatest that ever will be discovered; for as they are merely curious, without
being useful, it is not likely that any person will ever attempt to find one beyond it.6
At the start of this section we stated that M82 589 933 = 282 589 933 − 1 was the largest prime
at present (2019).
By using the sum of the geometric series (see Introductory Chapter for sum and definition
of geometric series) which we will just state:
a (1 − rn )
(4.29) a + ar + ar2 + ⋯ + arn−1 = .
1−r
Proof.
We assume that 2p − 1 is prime. The proper factors of N = 2p−1 (2p − 1) are the powers of 2
starting with 20 = 1 to 2p−1 and then their multiples with the prime 2p − 1. Hence the list
of proper factors of N is given by:
6
An Elementary Investigation of the Theory of Numbers by Peter Barlow, page 43.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 199
1, 2, 22 , ⋯ , 2p−2 , 2p−1 ,
⏟⎵⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⎵⏟ p − 1, 2 (2p − 1) , 22 (2p − 1) , ⋯ , 2p−2 (2p − 1) .
2⏟⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⏟ (∗)
First part Second part
We do not include the factor 2p−1 (2p − 1) because it is not a proper factor of
N = 2p−1 (2p − 1) .
Dividing this list into two parts by first summing all the powers of 2 and then the multiples
of powers of 2 with the prime 2p − 1.
Summing the powers of 2 which is the first part of the numbers in the list (∗):
1 + 2 + 22 + 23 + ⋯ + 2p−1 .
This is a geometric series with a = 1, r = 2, and n = p. Applying the sum formula (4.29)
yields
1 (1 − 2p ) (1 − 2p )
1 + 2 + 22 + 23 + ⋯ + 2p−1 = = = − (1 − 2p ) = 2p − 1. (‡)
1−2 −1
Summing the multiples of 2p − 1 with powers of 2 which is the second part of the
numbers in the list (∗):
1 (1 − 2p−1 ) (1 − 2p−1 )
1 + 2 + 22 + 23 + ⋯ + 2p−2 = = = 2p−1 − 1.
1−2 −1
Putting this into the previous calculation (∗∗) gives
Adding equations (‡) and (‡‡) which gives the sum of all the proper factors of N,
1 + 2 + 22 + ⋯ + 2p−1 + ⏟⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⏟
⏟⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⏟ (2p − 1) + 2 (2p − 1) + ⋯ + 2p−2 (2p − 1)
=2p −1 =(2p −1)[2p−1 −1]
=
⏟ (2p − 1) [2p−1 ] = N.
Simplifying
Since the sum of all the proper factors is (2p − 1) [2p−1 ] = N, so N is a perfect number.
This completes our proof.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
200 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
2000 years after Euclid, one of the greatest mathematicians of all time, Euler (pronounced
‘oiler’) proved that the converse of the above theorem is also true.
N = 2p−1 (2p − 1)
Proof.
See Exercises 4.5, question 9.
We don’t know. No one has been able to find one, but this does not mean there aren’t any.
This is one of the oldest conjectures in mathematics. Our intuition indicates there aren’t
any, but see Example 4.24 later in this section.
Now we introduce the sigma function and relate it to perfect and prime numbers.
Definition (4.31). The sigma function 𝜎 (n) of a natural number n is defined as the sum of
all the positive divisors (factors) of n. Let d1 , d2 , ⋯ , dk be all the divisors of n, then
𝜎 (n) = d1 + d2 + ⋯ + dk .
Example 4.22
Solution
𝜍 (10) = 1 + 2 + 5 + 10 = 18.
(b) Similarly, we have that the positive divisors of 12 are 1, 2, 3, 4, 6, and 12. Therefore,
𝜍 (12) = 1 + 2 + 3 + 4 + 6 + 12 = 28.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 201
(c) The positive divisors of 28 are 1, 2, 4, 7, 14, and 28. Adding these factors gives
𝜍 (28) = 1 + 2 + 4 + 7 + 14 + 28 = 56.
(d) 31 is prime, so the only divisors are 1 and 31. Adding these two numbers gives
𝜍 (31) = 1 + 31 = 32.
What do you predict the sigma function of a prime number will be?
𝜎 (p) = p + 1.
Proof.
Exercises 4.5, question 10.
From the previous example part (c) we have 𝜎 (28) = 56 = 2 × 28. Recall 28 is a perfect
number.
What do you think the sigma function will be for a perfect number n?
𝜎 (n) = 2n.
Proof.
Let d1 , d2 , ⋯ , dk−1 , and dk be the proper factors of the given n. Note that n is also a factor
of n. We are given that n is a perfect number, therefore
𝜎 (n) = d
⏟⎵1+
⎵⎵ 2 +⋯
d⎵⏟⎵⎵⎵+
⎵⏟dk +n = n + n = 2n.
=n because n is a perfect number
202 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Therefore, 𝜎 (6) = 2 × 6 = 12 and 𝜎 (496) = 2 × 496 = 992 because 6 and 496 are perfect
numbers.
561 is not prime or perfect. We use the multiplicative property to evaluate 𝜎 (561).
The sigma function is multiplicative.
In the next subsection we prove the function 𝜎 (n) is multiplicative. We will show the
following property of the sigma function:
k k k k
If n = p1 1 × p22 × p33 × ⋯ × pmm where p’s are distinct primes then
k k k k k k k
𝜎 (n) = 𝜎 (p1 1 × p22 × p33 × ⋯ × pmm ) = 𝜎 (p1 1 ) × 𝜎 (p2 2 ) × 𝜎 (p3 3 ) × ⋯ × 𝜎 (pkmm ) .
Example 4.23
Determine 𝜍 (561).
Solution
Let us first decompose 561 into its prime factors (you can easily check that 561 is divisible by 3 and 11
by using appropriate tests):
561 = 3 × 11 × 17.
Clearly 3, 11, and 17 are distinct primes. Assuming 𝜍 (n) is multiplicative, therefore
If we add all the positive factors of 561 then we get 864, which implies that 561 is a deficient
number. For a deficient number n we have 𝜎 (n) < 2n, see Exercises 4.5, question 3.
In this example we easily evaluated 𝜎 (561) without listing all the factors of 561 and then
summing them. However, we do need to find the prime decomposition of n.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 203
pk+1 − 1
𝜎 (pk ) = .
p−1
Proof.
Listing all the positive factors of pk where p is prime we have 1, p, p2 , p3 , ⋯ , pk−1 , and pk .
Adding these factors gives 𝜎 (pk ):
1 (1 − pk+1 ) a (1 − rn )
k 2 k By a + ar + ar2 + ⋯ + arn−1 =
𝜎 (p ) = 1 + p + p + ⋯ + p = [ 1−r ]
1−p with a = 1, r = p and n = k + 1.
pk+1 − 1 Multiplying numerator
= [ ]
p−1 and denominator by − 1.
pk+1 − 1
We have shown 𝜎 (pk ) = , which completes our proof.
p−1
Example 4.24
Determine 𝜍 (945).
Solution
The prime decomposition of 945 = 5 × 189 = 5 × 9 × 21 = 5 × 32 × 3 × 7 = 33 × 5 × 7.
Since these are distinct primes and using that the sigma function is multiplicative, so
Hence 𝜍 (945) = 1920. Adding all the positive factors of 945 gives 1920, which means 945 is an abun-
dant number. Your intuition suggests that an odd number cannot be abundant because it does not
have a factor which is half of 945. This 945 is the only odd number below 1000 which is abundant.
For an abundant number n we have 𝜎(n) > 2n, see Exercises 4.5, question 3.
204 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
Proof.
Since p and q are distinct primes, so by Exercises 2.1, question 5 (ii) we have
gcd (pk , qm ) = 1.
Listing the factors of n = pk × qm where p and q are distinct primes in a table and sum-
ming these using the geometric sum series formula (4.29) we have:
qm − 1
Factors of qm q, q2 , ⋯ , qm−1 , qm q(
q−1 )
qm − 1
Factors of p × qm pq, pq2 , ⋯ , pqm−1 , pqm pq (
q−1 )
qm − 1
Factors of p2 × qm p2 q, p2 q2 , ⋯ , p2 qm−1 , p2 qm p2 q (
q−1 )
⋮ ⋮ ⋮
qm − 1
Factors of pk × qm pk q, pk q2 , ⋯ , pk qm−1 , pk qm pk q (
q−1 )
qm − 1 pk+1 − 1
= q( )( ). (∗)
q−1 p−1
Adding the first entry in the last column in the table to this summation in (∗) gives
qm − 1 pk+1 − 1 pk+1 − 1
𝜎 (pk × qm ) = q ( )( )+( )
q−1 p−1 p−1
pk+1 − 1 qm − 1 pk+1 − 1
=( ) [q ( ) + 1] [Factorizing ( )]
p−1 q−1 p−1
pk+1 − 1 qm+1 − q + q − 1 pk+1 − 1 qm+1 − 1
=( )[ ]=( )[ ].
p−1 q−1 p−1 q−1
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 205
Using the previous Proposition (4.35) to evaluate 𝜎 (pk ) and 𝜎 (qm ) gives:
pk+1 − 1 qm+1 − 1
𝜎 (pk ) = and 𝜎 (qm ) = .
p−1 q−1
pk+1 − 1 qm+1 − 1
Substituting this 𝜎 (pk ) = and 𝜎 (qm ) = into the above yields
p−1 q−1
pk+1 − 1 qm+1 − 1
𝜎 (pk × qm ) = ( )×[ ] = 𝜎 (pk ) × 𝜎 (qm ) .
p−1 q−1
Proof.
Exercises 4.5, question 11.
Summary
A natural number n is called a perfect number if the sum of its proper factors is equal to n. Mersenne
primes can be used to create even perfect numbers.
We can use the multiplicative property of the sigma function 𝜍 (n) to evaluate 𝜍 (n), which tells us
the sum of divisors of n. This 𝜍 (n) also tells us whether n is a prime, perfect, abundant, or deficient
number.
If n = p × q then 𝜍 (n) = 𝜍 (p) × 𝜍 (q) where p and q are distinct primes.
EXERCISES 4.5
206 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
.........................................................................................................
Supplementary Problems 4
PE R F E CT N U MB ERS A ND T H E S I G M A F U N C T I O N ( 1 9 5 – 2 0 8 ) 207
4.3. Determine the least non-negative 4.12. *Find at least three factors of the
residue x ( mod 11) such that composite integer 1 111 111 111.
1
71 000 003 ≡ x ( mod 11) . 4.13. Show that (10e − 1), where e is an
9
even integer, is divisible by 11.
4.4. (i) Evaluate the multiplicative inverse
4.14. Show that 102n ≡ 1 ( mod 99).
of 30 ( mod 31).
4.15. Explain what the difference between
(ii) Find the least non-negative
pseudoprime and Carmichael
residue x ( mod 31) such that
number is.
5 (29!) ≡ x ( mod 31) . Show that 4369 is a pseudoprime.
4.16. Show that 1105 is a Carmichael
4.5. Determine the multiplicative inverse number.
of 11! ( mod 13).
4.17. Let p and q be distinct primes. Prove
4.6. Let p be a prime. Show that the that pq−1 + qp−1 ≡ 1 ( mod pq).
multiplicative inverse of
4.18. Let p be an odd prime. Prove that
(p − 3)! ( mod p) is (p − 2) ( mod p).
p | (2p−1 − 1) .
4.7. Factorize the following integers into
n!
their prime factors: 4.19. *(i) The notation n Cr =
r! (n − r)!
(a) 214 − 1 (b) 215 − 1 where 1 ≤ r ≤ n. Show that
(c) 216 − 1. p
Ck ≡ 0 ( mod p)
5n
4.8. (a) Show that 31 is a factor of 2 − 1. where p is prime and 1 ≤ k < p.
(b) Show that 2047 is a factor of (ii) Prove that
21 100 001 111 − 1. Find another factor
(a + b)p ≡ ap + bp ( mod p)
of this number.
where p is prime.
4.9. Let m, n, and a be positive integers
greater than 1. Prove that if m | n (iii) Prove that
p
then (a1 + a2 + ⋯ + an ) ≡
p p p
a1 + a2 + ⋯ + an ( mod p)
(am − 1) | (an − 1) . where p is prime.
[Hint: ars − 1 = (ar − 1) (ar(s−1) + 4.20. **Prove that if a ≡ b ( mod p) where
ar(s−2) + ar(s−3) + ⋯ + ar + 1).] p is prime then ap ≡ bp ( mod p2 ).
4.10. (a) Without a calculator, show that 4.21. Disprove the following result:
11 55
5 − 1 is a factor of 5 − 1. xn ≡ x ( mod n) .
(b) Determine the prime 4.22. Show the following result:
decomposition of 510 − 1. For a composite integer n we have
5
4.11. Factorize 10 + 1 = 100 001. xn − 1 = (xm − 1) Pn−m (x) , where
[Hint: If n is odd then xn + 1 = Pn−m (x) is a n − m degree
(x + 1) (xn−1 − xn−2 + xn−3 − xn−4 + polynomial (defined in the
⋯ − x + 1).] Introductory Chapter) and integer
m > 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
208 4 A SURV EY OF M O D U L A R A R I T H M ET I C W I TH P R I M E M O D U L I
4.23. (i) Show that if n a and 4.29. ***Prove that there are infinitely
n−1
a ≢ 1 ( mod n) then n is
2 many pseudoprimes to the base a
composite. where a > 1.
(ii) Explain why 4.30. Prove that
1729−1 k k k
12 2 ≡ 1 ( mod 1729) 𝜏 (p11 × p22 × ⋯ × pr r ) =
but 1729 is composite. (k1 + 1) × (k2 + 1) × ⋯ × (kr + 1)
n
4.24. Prove the following is false: if 2 − 1 where 𝜏 (n) gives the number of
is composite then n is composite. positive divisors of n. This 𝜏 (n) was
4.25. *Prove that n (2n − 1) for all n ≥ 2. defined in Chapter 1.
4.26. We say different positive integers m [Hint: You can assume that 𝜏 (n) is
and n are amicable ⇔ the sum of the multiplicative.]
proper divisors of m is equal to n and 4.31. *Let
the sum of the proper divisors of n is gcd (x, 5) = gcd (x, 29) = gcd(x, 73) = 1.
equal to m. Show that 220 and 284
Prove that
are amicable.
4.27. Let p be an odd prime. Prove that x(5×29×73)−1 ≡ 1 ( mod (5 × 29 × 73)) .
pn
[(p − 1)!] ≡ −1 ( mod p) . 4.32. *Let p be an odd prime. Prove that
4.28. *Let p be an odd prime. Prove that p+1
2
p−1 p−1 2 22 42 62 ⋯ (p − 1) ≡ (−1) 2 ( mod p) .
(p − 1)! ≡ (−1) 2 [( )!] ( mod p) .
2
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
..............................................................................................................................
Euler’s Generalization of
5 Fermat’s Theorem
..............................................................................................................................
We will answer this question in Example 5.12 of Section 5.2 by working with the composite
modulo 100. We cannot use Fermat’s Little Theorem (4.1) because that is only valid when
we have a prime modulo:
What is 𝜙 (n) ?
This is called Euler’s (pronounced oiler’s) phi or totient function and is denoted by 𝜙 (n).
This symbol 𝜙 is the Greek letter ‘phi’ pronounced ‘fee’ as in ‘fees’. Gauss gave us the symbol
𝜙 (n), whilst Euler had used 𝜋N for 𝜙 (N).
In RSA (as discussed in Section 3.5) encryption applications, a number is raised to a large
power and the remainder is the quantity of interest.Since we are interested in remainders
and large indices, so we work with modular arithmetic. Working with something that gives
1 (mod n) is easy to compute because
210 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Without RSA encryption, we could not securely transmit confidential details such as our
credit card number over the internet. 1
As an example, the RSA encryption system works with modulo n such that n = p × q
where p, q are large primes. Decryption of this relies on computing Euler’s totient function
𝜙 (n) which is difficult to evaluate if you don’t know the prime factorization of n, as we will
see later. In this section, we will discover that if you know the factorization of n, which is
no easy task, then finding 𝜙 (n) is not difficult.
No, because you choose the number n = p × q to be one whose factorization you know but
others don’t. This means that the system is hard to break unless you know the prime factor-
ization of n upfront. (Factorization is enormously difficult even for powerful computers.)
𝜙 (n)
Another application of 𝜙 (n) is that gives the probability that a number we choose
n
between 1 and n is relatively prime to n.
It is going to be all the residues a ( mod n), such that gcd (a, n) = 1. The function 𝜙(n)
counts the number of incongruent residues that have an inverse modulo n.
We need something which will count the number of incongruent residues ( mod n) that
have an inverse. This counting is done by Cardinality which was defined in the Introductory
Chapter:
The Cardinality, denoted Card, of a set is the number of elements in the set. For
example,
Euler’s totient function (5.1). Let n be a natural number. The Euler totient function 𝜙 (n)
is defined as
𝜙 (n) = Card {a ∶ gcd (a, n) = 1 and 1 ≤ a ≤ n} .
Well gcd (a, n) = 1 implies that a and n are relatively prime. Decoding the notation,
⏟ {a
Card ∶
⏟ gcd⎵(a,
⏟⎵ ⎵⏟⎵ =1
n)⎵⎵⏟ ≤ a ≤ n }.
and 1⏟⎵⏟⎵⏟
counts such that between 1 and n
a and n are relatively prime
1
https://blogs.ams.org/mathgradblog/2014/03/30/rsa/.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
EU L E R ’ S TOT I E N T F U N C T I O N ( 2 0 9 – 2 2 2 ) 211
The number 𝜙 (n) gives how many integers between 1 and n are relatively prime to n.
Hence 𝜙 (n) gives the number of incongruent residues that have an inverse modulo n.
Example 5.1
Solution
(a) 𝜙 (6) counts the number of integers from 1 to 6 which are relatively prime to 6.
Hence evaluating gcd of the numbers between 1 and 6, with 6:
gcd(5, 6) = 1 , gcd(6, 6) = 6.
The only numbers which are relatively prime to 6 are 1 and 5, therefore
(b) Similarly, 𝜙 (10) is the number of integers between 1 and 10 which only have a common factor
of 1 with 10:
= Card {1, 3, 7, 9} = 4.
(c) For 𝜙 (5) we note that 5 is prime, so all the integers between 1 and 4 are relatively prime to 5:
= Card {1, 2, 3, 4} = 4.
Table 5.1
n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
𝜙 (n) 1 1 2 2 4 2 6 4 6 4 10 4 12 6 8 8 16 6 18 8
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
212 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Each of the n values is prime and Euler’s totient function 𝜙 (n) for these is one less than
n. This is always the case.
Proof.
We assume n is prime. Then all the integers 1, 2, 3, 4, …, n − 1 have only a common factor
of 1 with prime n. Recall Card counts the number of elements in a set:
= Card {1, 2, 3, 4, ⋯ , n − 1} = n − 1.
𝜙 (n) = n − 1 ⇔ n is prime.
EU L E R ’ S TOT I E N T F U N C T I O N ( 2 0 9 – 2 2 2 ) 213
Proof.
(⇒). Assume 𝜙 (n) = n − 1. By the definition of 𝜙 (n) we have
Reference (∗) means that there are n − 1 natural numbers between 1 and n which are
relatively prime to n. For a = 1, 2, 3, ⋯ , n − 1 we have
gcd (a, n) = 1.
Result (5.3) means there are n − 1 incongruent residues which have an inverse modulo
prime n.
Not practical, because if n is a large integer then we will show that to evaluate 𝜙 (n) you need
to find the prime factorization of n first.
Recall for evaluating 𝜙 (n) we do not need to find the natural numbers ≤ n that are rel-
atively prime to n, but just how many. We need to develop a much more efficient way to
evaluate 𝜙 (n), which is demonstrated next. First we examine prime powers.
Trying to find the number 𝜙 (pk ) where k is a natural number will quickly become difficult,
as pk will become large very rapidly. Proposition (5.4) given next provides us with a method
to reduce the computations.
To help prepare us for proving this, we’ll first look at two examples to see it working.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
214 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Example 5.2
Compute 𝜙 (16).
Solution
The number 𝜙 (16) tells us how many integers between 1 and 16 are relatively prime to 16.
The natural numbers between 1 and 16 that have a common factor greater than 1 with 16 are the
even numbers:
S = {2, 4, 6, 8, 10, 12, 14, 16}.
We can rewrite this set as
[As a check, we can list the set: 𝜙 (16) = Card {1, 3, 5, 7, 9, 11, 13, 15} = 8.]
Alternatively, we could have used the above Proposition (5.4). Note that 16 = 24 :
𝜙 (24 ) = 24 − 23 = 16 − 8 = 8.
Example 5.3
Evaluate 𝜙 (27).
Solution
Like in Example 5.2, we write the set S whose elements have a common factor of greater than 1 with
27 = 33 (these incongruent residues don’t have an inverse modulo 27):
Hence 𝜙 (27) = 27 − 9 = 18 because the 9 integers in S are not relatively prime to 27.
We can check this by listing the integers which are relatively prime to 27:
𝜙 (27) = Card {1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26} = 18.
⏟⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⎵⏟
There are 18 elements in this set (multiples of 3 missing)
EU L E R ’ S TOT I E N T F U N C T I O N ( 2 0 9 – 2 2 2 ) 215
Notice that in both the above examples, the set of numbers with common factors greater
than 1 with pk was given by
and in both cases the Cardinality of this set was Card {S} = pk−1 . So for these examples
𝜙 (pk ) = pk − pk−1 .
We are now in a good position to prove the general statement of Proposition (5.4):
If p is prime and k is a natural number then
𝜙 (pk ) = pk − pk−1 .
This implies there are pk − pk−1 incongruent residues that have an inverse modulo pk .
Follow this proof very carefully, as the reasoning is based on Examples 5.2 and 5.3.
Proof.
The integers between 1 and pk which have a common factor greater than 1 with pk are
Why?
Card {S} = Card {p, 2p, 3p, 4p, 5p, ⋯ , pk−1 p} = pk−1 .
All the other integers below pk are relatively prime to pk apart from the ones in this set S.
𝜙 (pk ) is the number pk minus the number of integers in the set S which is pk−1 :
216 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Example 5.4
Solution
In each case we apply the previous Proposition (5.4):
𝜙 (pk ) = pk − pk−1 .
This answer means there are nearly eight million (7 812 500) natural numbers below 510 which
only have a common factor of 1 with 510 .
How many natural numbers have a common factor > 1 with 510 ?
This means that there are 110 natural numbers which are relatively prime to 121. (This 𝜙 counts
all the integers from 1 to 121 but with 11, 22, 33, 44, …, 110, and 121 (multiples of 11) missing,
hence 121 − 11.)
Note we don’t have to find which numbers are relatively prime to pk . The number 𝜙 (n)
for each n of Example 5.4 is well over half of n.
Why?
Because each of these numbers only has one prime divisor (>2), so only the multiples of
that prime are missing.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
EU L E R ’ S TOT I E N T F U N C T I O N ( 2 0 9 – 2 2 2 ) 217
This formula is only valid for prime powers. We would like a formula for 𝜙 (n) where n is
any natural number.
Recall from the last chapter’s Definition (4.34) that a multiplicative function f satisfies
Theorem (5.5). Euler’s totient function 𝜙(m × n) is multiplicative (m and n are natural
numbers):
𝜙 (m × n) = 𝜙 (m) × 𝜙 (n) provided gcd(m, n) = 1.
Proof.
See Exercises 5.1, question 25.
Example 5.5
Solution
We write 111 in its prime decomposition as 111 = 3 × 37. Since gcd(3, 37) = 1, we can use the multi-
plicative property of 𝜙 (n):
𝜙 (111) = 𝜙 (3 × 37)
= 𝜙 (3) × 𝜙 (37) [By 𝜙 (m × n) = 𝜙 (m) × 𝜙 (n)]
= (3 − 1) (37 − 1) = 72 [By Prop (5.2) 𝜙 (p) = p − 1]
218 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Proof.
See Exercises 5.1, question 21.
Proof.
By Exercises 2.1, question 5 (ii):
If p and q are distinct primes then gcd( pn , qm ) = 1.
k k
Using this and the previous Corollary (5.6) with m1 = p11 , …, mr = pr r gives us our result.
How can we use this result (5.7) to find 𝜙 (n) of any natural number n greater than 1?
5 = 5, 10 = 2 × 5, 24 = 23 × 3, 100 = 22 × 52 , ⋯ .
We use this theorem along with 𝜙 being multiplicative to prove the following result.
This looks like a tedious formula. Unless you have a lot of primes in your n you will find
this straightforward to apply, but first we must prove this.
How?
EU L E R ’ S TOT I E N T F U N C T I O N ( 2 0 9 – 2 2 2 ) 219
Proof.
k k k k
We are given that n = p11 × p22 × p33 × ⋯ × pr r so we have
k k k k
𝜙 (n) = 𝜙 (p11 × p22 × p33 × ⋯ × pr r )
k k k k
= 𝜙 (p11 ) × 𝜙 (p22 ) × 𝜙 (p33 ) × ⋯ × 𝜙 (pr r ) [By (5.7)]
k k −1 k k −1 k k −1
= (p11 − p11 ) × (p22 − p22 ) × ⋯ × (pr r − pr r ) [By (5.4) 𝜙 (pk ) = pk − pk−1 ] .
k k k
Proposition (5.9). Let n = p11 × p22 × ⋯ × pr r , then
1 1 1
𝜙 (n) = n (1 − ) (1 − ) ⋯ (1 − ) .
p1 p2 pr
Proof.
See Exercises 5.1, question 22.
This result (5.9) is easier to use than (5.8) to evaluate the number 𝜙 (n).
Example 5.6
Compute the following numbers (a) 𝜙 (100) (b) 𝜙 (101) (c) 𝜙 (144) (d) 𝜙 (2010)
Solution
In each case we apply the formula of Proposition (5.9).
(a) We first decompose 100 into its primes:
2
100 = 102 = (2 × 5) = 22 × 52 .
1 1 1 4
𝜙 (100) = 100 (1 − ) (1 − ) = 100 ( ) ( ) = 40.
2 5 2 5
What does this answer of 40 mean?
There are 40 natural numbers below 100 which are relatively prime to 100. We do not need to
locate them. Notice how this formula works:
Half the natural numbers (all the odd numbers) up to 100 are relatively prime with 100.
1
These 50 odd numbers below 100 are counted by 100 ( ) = 50.
2
Of these 50 odd numbers, 1/5 of them are multiples of 5 and the remaining 4/5 are relatively
4
prime with 100, which is given by 50 ( ) = 40.
5 (continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
220 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Hence 𝜙 (101) = 101 − 1 = 100. This means there are 100 natural numbers which are rela-
tively prime to 101. This answer is much larger than the 40 natural numbers which are relatively
prime to 100.
Notice our answers to the last two parts:
2
144 = 122 = (22 × 3) = 24 × 32 .
1 1 1 2
𝜙 (144) = 144 (1 − ) (1 − ) = 144 ( ) ( ) = 48.
2 3 2 3
This implies there are 48 incongruent residues that have an inverse modulo 144. Since the
only primes involved in producing 144 are 2 and 3, so 𝜙 (144) counts the number in the set of
natural numbers below 144 which have no multiples of 2 or 3:
2010 = 201 × 10
= (67 × 3) × (5 × 2) = 2 × 3 × 5 × 67.
1 1 1 1
𝜙 (2010) = 2010 (1 − ) (1 − ) (1 − ) (1 − )
2 3 5 67
1 2 4 66
= 2010 ( ) ( ) ( ) ( ) = 528.
2 3 5 67
There are 528 integers between 1 and 2010 which have a gcd of 1 with 2010. There are 528
natural numbers which are not multiples of 2, 3, 5, or 67 below 2010.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
EU L E R ’ S TOT I E N T F U N C T I O N ( 2 0 9 – 2 2 2 ) 221
As n gets larger, we might have expected 𝜙 (n) to get larger as well. This is clearly false, as
can be seen from the graph. An example of this is 𝜙 (59) = 58 but 𝜙 (60) = 16. Of course,
the general trend is upwards for large n, as you can see from the following table:
Table 5.2 The number 𝜙 (n) for various values of n.
You might have noticed from this Table 5.2 that the number 𝜙 (n) is even for all n. This
is no coincidence, for we have the following general result:
Proof.
k k
Let the prime decomposition of n be written as n = p11 × ⋯ × pr r . Then by Proposition
(5.8):
k k −1 k k −1 k k −1 k k −1
𝜙 (n) = (p11 − p11 ) × (p22 − p22 ) × (p33 − p33 ) × ⋯ × (pr r − pr r )
k −1 k −1 k −1
= p11 (p1 − 1) × p22 (p2 − 1) × ⋯ × pr r (pr − 1) [Factorizing].
If the only prime in n > 2 is p1 = 2 then we have 𝜙 (n) = 2k1 −1 (2 − 1) which is even because
2k1 −1 is a multiple of 2 (k1 > 1 because we are given n > 2).
If we have any distinct primes from 2 in n then
k −1 k −1 k −1
𝜙 (n) = p11 (p1 − 1) × p22 (p2 − 1) × ⋯ × pr r (pr − 1)
is even because one of the primes must be odd and an odd number minus 1 gives an even
number.
In either case, we have our required result.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
222 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Summary
Euler’s totient function 𝜙 (n) for a positive integer n > 1 gives the number of incongruent residues that
have an inverse modulo n:
EXERCISES 5.1
(Brief solutions at end of book. Full 8. Are there any natural numbers n such
solutions available at <http://www.oup.co. that 𝜙 (n) = n?
uk/companion/NumberTheory>.)
9. What is the probability that a number
1. Determine the Euler totient function m ∈ {1, 2, 3, ⋯ , 164} is relatively
𝜙 (n) of the following prime numbers: prime to 164?
(a) 13 (b) 211 (c) 311 10. (a) Determine the number of
(d) 1973 (e) 1999 (f) 2017 incongruent residues that have an
inverse modulo 310.
2. Find the Euler totient function 𝜙 (n) of
the following numbers: (b) Show that the probability of a
given residue a ( mod pn ) has a
(a) 15 (b) 64 (c) 200 1
(d) 1000 (e) 1001 (f) 666 multiplicative inverse is 1 − where p
p
is prime.
3. Find the Euler totient function 𝜙 (n) of
the following numbers: 11. Solve the following equations for a
1000 1000 general n such that:
(a) 2 (b) 3
(c) 51000 (d) 71000 n n
(a) 𝜙 (n) = (b) 𝜙 (n) =
2 3
Interpret your result in each case. 12. Give an example of a natural number n
n
m
4. Show that 𝜙 (p ) = 𝜙 (p) p m−1
where p such that 𝜙 (n) < . Give reasons for
3
is a prime and m is a natural number. your choice.
1 n 13. Let n = 2k1 × 3k2 × 5k3 . Show that
5. Show that 𝜙 (2n ) = (2 ) where n is a
2
natural number. 4
𝜙 (n) = n.
1 n 15
What does 𝜙 (2n ) = (2 ) signify?
2 14. Let p be prime and p | n . Prove that
6. Show that 𝜙 (10m ) = 4 (10m−1 ) where
m is a natural number. n (p − 1)
𝜙 (n) ≤ .
p
7. Prove that 𝜙 (nm ) = nm−1 𝜙 (n).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
.........................................................................................................
In the last section we defined 𝜙 (n) which gives the number of integers between 1 and n that
are relatively prime to n. In this section we find the integers which are relatively prime to n
(or the incongruent residues that have an inverse modulo n).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
224 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
5.2.1 Introduction
ap−1 ≡ 1 (mod p) .
34 ≡ 1 (mod 10)
98 ≡ 1 (mod 16)
57400 ≡ 1 (mod 1000).
This last result, 57400 ≡ 1 (mod 1000), says the last three digits of 57400 are 001.
Recall having ax ≡ 1 (mod n) is a useful result because it cuts down on the arithmetic
when evaluating powers of residues modulo n.
In each of the above cases the moduli 10, 16, 1000 are composite and the index is not 1
less than the moduli 10, 16, 1000 respectively.
In this section we answer the question of what conditions lead to ax ≡ 1 (mod n) and ex-
amine how x and n are related.
Example 5.7
Solution
(i) We have 𝜙(10) = 𝜙(2 × 5) = 𝜙(2) × 𝜙(5) = 1 × 4 = 4.
What does this mean?
There are four natural numbers below 10 which are relatively prime to 10.
(ii) Note that 𝜙 (10) = 4 does not tell us which four incongruent residues have an inverse. For a
small number like 10 we can list them; it is the four integers which are relatively prime to 10,
and these are 1, 3, 7, and 9 because
gcd (1, 10) = gcd (3, 10) = gcd (7, 10) = gcd (9, 10) = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Example 5.8
ar1 ≡ x1 (mod 10) , ar2 ≡ x2 (mod 10) , ar3 ≡ x3 (mod 10) and ar4 ≡ x4 (mod 10).
Solution
Substituting r1 = 1, r2 = 3, r3 = 7, r4 = 9, and a = 3, gives
It is no coincidence that each of our results were congruent to the given values of rj . This
is because each of these rj ’s is relatively prime to 10, as established in Example 5.7 (ii). [In
Example 5.7 (ii) we found these numbers to be 1, 3, 7, and 9, which are the given rj values
in Example 5.8.]
This property isn’t unique to n = 10, but will hold for any n > 1; we’ll see this for modulo
n = 9 next.
Example 5.9
Let r1 = 1, r2 = 2, r3 = 4, r4 = 5, r5 = 7, r6 = 8 and a = 2.
Determine the least positive residues xj for j = 1, 2, 3, ⋯ , 6 such that:
Solution
Substituting r1 = 1, r2 = 2, r3 = 4, r4 = 5, r5 = 7, r6 = 8, and a = 2 into (∗) gives
ar1 ≡ 2 × 1 ≡ 2 ≡ r2 (mod 9)
ar2 ≡ 2 × 2 ≡ 4 ≡ r3 (mod 9)
ar3 ≡ 2 × 4 ≡ 8 ≡ r6 (mod 9)
ar4 ≡ 2 × 5 ≡ 1 ≡ r1 (mod 9)
ar5 ≡ 2 × 7 ≡ 5 ≡ r4 ( mod 9)
ar6 ≡ 2 × 8 ≡ 7 ≡ r5 (mod 9).
226 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
rj r1 r2 r3 r4 r5 r6
2rj (mod 9) r2 r3 r6 r1 r4 r5
The set of natural numbers, rj ’s, in the above example is called a reduced residue system
modulo 9, that is
It is those incongruent residues which have an inverse modulo n. Hence it is the set of
residues {r1 , r2 , ⋯ , r𝜙(n) } which only have a common factor of 1 with n and any two differ-
ent members, ri and rj , are not congruent modulo n, that is
Definition (5.11). A reduced residue system modulo n is the set of integers {r1 , r2 , ⋯ , r𝜙(n) }
such that
(i) gcd (ri , n) = 1 for i = 1, 2, 3, ⋯ , 𝜙 (n).
(ii) ri ≢ rj (mod n) where i ≠ j.
gcd (1, 12) = gcd (5, 12) = gcd (7, 12) = gcd (11, 12) = 1.
(†) is not the only reduced residue system modulo 12. Here is another:
What is the difference between the complete and reduced residue system?
A reduced residue system contains only those members in the complete system which are
relatively prime to n. Like (†) for modulo 12.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Note the difference between 𝜙 (n) and the reduced residue system modulo n.
𝜙 (n)—gives the number of incongruent residues which are relatively prime to n. The
reduced residue system modulo n gives the set of incongruent residues that are relatively
prime to n. Clearly this set will have 𝜙 (n) members.
gcd (a, n1 × n2 ⋯ × nk ) = 1.
Proof.
See complete solution to Exercises 1.3, question 15 (ii).
Example 5.10
Solution
By Example 5.9 we have:
rj 1 2 4 5 7 8
2rj (mod 9) 2 4 8 1 5 7
Recall the rj ’s represent the reduced residue system modulo 9, and as you can observe from the table:
2rj ≡ rk (mod 9) .
where gcd (9, 1) = gcd (9, 2) = gcd (9, 4) = gcd (9, 5) = gcd (9, 7) = gcd (9, 8) = 1. Applying the pre-
vious Lemma (5.12) to these gcd’s gives
gcd (9, 1 × 2 × 4 × 5 × 7 × 8) = 1.
to (∗) gives
26 ≡ 1 (mod 9) .
228 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
Lemma (5.13). Let n >1 and gcd (a, n) = 1. If {r1 , r2 , r3 , ⋯ , r𝜙(n) } is a reduced residue
system modulo n then so is
Proof.
(1) No two members of S are congruent modulo n.
Suppose the following two residues are congruent modulo n:
We are given gcd (a, n) = 1, so applying the Cancellation Law (3.11) to arj ≡ ark (mod n)
gives
rj ≡ rk ( mod n).
This is a contradiction, so the arj ’s are not congruent to each other modulo n.
(2) Every member of S is relatively prime to n.
Since gcd (ri , n) = 1 and gcd (a, n) = 1, so applying Lemma (5.12):
if gcd (a, n1 ) = gcd (a, n2 ) = ⋯ = gcd (a, nk ) = 1 then gcd (a, n1 × n2 ⋯ × nk ) = 1 to
This gcd (a × ri , n) = 1 implies that ari and n are relatively prime, so ari must be a member
of reduced residue system modulo n:
ari ≡ rk (mod n) .
In the above, as S = {ar1 , ar2 , ar3 , ⋯ , ar𝜙(n) } is also a reduced residue system, so each
of these residues is congruent to one of the residues in {r1 , r2 , r3 , ⋯ , r𝜙(n) }.
Euler’s Theorem (5.14). Let n be an integer > 1 and gcd (a, n) = 1. Then
Proof.
Let {r1 , r2 , r3 , ⋯ , r𝜙(n) } be a reduced residue system modulo n. By the previous Lemma
(5.13) we have
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Each of the rj ’s is relatively prime to n, that is gcd (rj , n) = 1 for j = 1, ⋯ , 𝜙(n). Using
Lemma (5.12):
if gcd (n1 , a) = ⋯ = gcd (nk , a) = 1 then gcd (n1 × n2 ⋯ × nk , a) = 1,
on gcd (r1 , n) = gcd (r2 , n) = ⋯ = gcd (r𝜙(n) , n) = 1 gives
gives
a𝜙(n) ≡ 1 ( mod n).
This completes our proof.
Example 5.11
Solution
Since 200 is composite and gcd (3, 200) = 1, so we can use Euler’s Theorem to evaluate x.
We first determine 𝜙 (200).
How?
By Proposition (5.9):
1 1 1
𝜙 (n) = n (1 − ) (1 − ) ⋯ (1 − ) .
p1 p2 pr
What is the prime decomposition of 200?
230 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
1 1
𝜙 (200) = 200 (1 − ) (1 − ) = 80.
2 5
By applying Euler’s Theorem (5.14),
a𝜙(n) ≡ 1 (mod n) ,
with a = 3, n = 200 and 𝜙 (200) = 80 gives
However we need to evaluate 3170 ≡ x (mod 200). By the Division Algorithm we can write the index
170 as a multiple of 80 plus any remainder:
Therefore,
2
3170 ≡ 3(2×80)+10 ≡
⏟ (380 ) × 310 ≡ (1) 2 10 10
⏟ × 3 ≡ 3 ( mod 200). (∗)
By the rules of indices By (†)
This means that if we divide the large number 3170 by 200 the remainder is 49. Note we do not have
to find the decimal digits of 3170 .
Example 5.12
Solution
11205 has 213 digits, but we are not interested in finding all these digits.
We are only interested in the last two digits, so we need to determine the least non-negative residue
of 11205 modulo 100. (The remainder after dividing by 100 gives the last two digits.)
From previous calculations we have 𝜙 (100) = 40. We use Euler’s Theorem (5.14):
The gcd (11, 100) = 1, so applying this with a = 11 and n = 100 we have
We need to write the given index 205 as a multiple of 40 and any remainder by using the Division
Algorithm:
205 = (5 × 40) + 5.
Hence
5
11205 ≡ 11(5×40)+5 ≡ (1140 ) × 115 ≡ (1) 5 5 5
⏟ × 11 ≡ 11 ( mod 100).
By (∗∗ )
Next, we prove Fermat’s Little Theorem (also proved in the last chapter) using Euler’s
Theorem.
Fermat’s Little Theorem (5.15). If p is prime and p does not divide into a, then
ap−1 ≡ 1 (mod p) .
Proof.
We are given p a, so gcd (a, p) = 1. We can use Euler’s Theorem (5.14):
a𝜙(n) ≡ 1 (mod n)
Summary
A reduced residue system only includes those incongruent residues which have an inverse.
We can use Euler’s Theorem to evaluate powers of residues of any moduli n.
Let n be an integer greater than 1 and gcd (a, n) = 1, then
232 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
EXERCISES 5.2
(Brief solutions at end of book. Full 11. For the following either give a proof or
solutions available at <http://www.oup.co. exhibit a counterexample:
uk/companion/NumberTheory>.)
Let gcd (a, n) = 1 then
1. Let r1 = 1, r2 = 3, r3 = 5, r4 = 7, and
a = 3. Determine the least a𝜙(𝜙(n)) ≡ 1 (mod n) .
non-negative residues xj for 12. (a) Let gcd (a, n) = 1. Prove that
j = 1, 2, 3, 4 such that
arj ≡ xj (mod 8) . a−1 ≡ a𝜙(n)−1 (mod n) .
18. *(i) Let {r1 , r2 , r3 , ⋯ , r𝜙(n) } be a set 19. **Determine the last three digits of
of reduced residue system modulo n. 2019
Prove that 20192019 .
n n
r1 × r2 × r3 × ⋯ × r𝜙(n) ≡ ±1 ( mod n) . [Tower rule am = a(m ) .]
(ii) Prove Wilson’s Theorem.
.........................................................................................................
Supplementary Problems 5
(Brief solutions at end of book. Full 5.5. Find the last three digits of 20112011 .
solutions available at <http://www.oup.co.
5.6. Let n be odd. Determine a formula
uk/companion/NumberTheory>.)
for 𝜙 (2m n) where m is a natural
5.1. (i) Determine 𝜙 (100) where 𝜙 is the number.
Euler totient function.
5.7. Solve 23x ≡ 5 (mod 100).
(ii) Determine the last two
digits of 5.8. Let n = 2m 3k . Show that 𝜙 (n) = n/3.
20132013 . n
Explain what is meant by 𝜙 (n) = .
3
(iii) **Find the last two
5.9. (i) Explain what is meant by
digits of
2013 n
20132013 . 𝜙 (n) = .
n n 2
[Hint: Tower rule am = a(m ) .] n
(ii) Prove that if 𝜙 (n) = then
(iv) Explain why we cannot use 2
Euler’s Theorem a𝜙(n) ≡ 1 (mod n) to n = 2m .
find the least positive residue 5.10. (i) Determine the least non-negative
x ( mod 100) in the following residue x (mod 4) in the following:
congruence: 34 + 32 + 2 (3) ≡ x ( mod 4) .
20142014 ≡ x (mod 100) .
5.2. Determine the number 𝜙 (n) for the (ii) Show that
following integers: a4 + a2 + 2a ≡ 0 ( mod 4)
(a) 1000 for any integer a.
(b) 10 000 5.11. Decryption in an RSA system relies
(c) 100 000 on evaluating Euler’s phi function
(d) 1 000 000 𝜙 (n) where n = pq and p and q are
What do you notice about your results?
large distinct primes. Of course,
once we know the prime
5.3. Find the values of factorization of n then 𝜙 (n) is easy
(a) 𝜙 (2014) (b) 𝜙 (2015) to work out. For the following prime
(c) 𝜙 (2016) (d) 𝜙 (2017) multiplications compute the number
[2017 is prime.] 𝜙 (n) in each case.
5.4. Determine the natural numbers n (a) n = 1 299 709 × 15 485 863
4n (b) n = 1 726 943 × 179 424 673
such that 𝜙 (n) = .
5
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
234 5 E UL E R’ S G EN E R A L I Z AT I O N O F F ERM AT ’ S T H E O R E M
..............................................................................................................................
In this chapter we will see the limitations of using Euler’s Theorem to evaluate the least
positive residue x such that am ≡ x (mod n). We find the first positive index k such that
ak ≡ 1 (mod n).
So far we have only dealt with linear congruences ax ≡ b (mod n), but in this chapter
we solve non-linear congruences such as ax k ≡ b (mod n). We solve these non-linear con-
gruences by converting them to linear form and then use the results of Chapter 3 to solve
them.
Since we are interested in the last three digits, so we need to work with modulo 1000. We
know the gcd (7, 1000) = 1, so we can use Euler’s Theorem (5.14):
a𝜙(n) ≡ 1 (mod n) .
1 1
We have 𝜙 (1000) = 1000 (1 − ) (1 − ) = 400. Therefore, by applying Euler’s Theorem
2 5
with a = 7, n = 1000 we have 7400 ≡ 1 (mod 1000). However, we want to find the least pos-
itive residue x in
7311 ≡ x (mod 1000) . (∗)
The index 311 < 400, so using 7400 ≡ 1 (mod 1000) will not help. This means that Euler’s
Theorem in trying to help find x in (∗) is of no use. In this section we will see how we can
reduce this calculation. We find the last three digits in Example 6.6 later in this section by
first determining the smallest index k such that
7k ≡ 1 (mod 1000) .
236 6 P R IM I TI VE R O OTS A N D I N D I C ES
Example 6.1
Solution
We evaluate with base 4 to various indices until we get to 1 (mod 13):
41 ≡ 4 ≢ 1 (mod 13)
42 ≡ 16 ≡ 3 ≢ 1 (mod 13)
43 ≡ 64 ≡ 12 ≢ 1 (mod 13)
2
44 ≡ (42 ) ≡ 32 ≡ 9 ≢ 1 (mod 13)
45 ≡ 44 × 4 ≡ 9 × 4 ≡ 36 ≡ 10 ≢ 1 (mod 13)
46 ≡ 45 × 4 ≡ 10 × 4 ≡ 40 ≡ 1 (mod 13) .
It makes the arithmetic of evaluating indices much easier because 1m ≡ 1 (mod n).
The first index of an integer which hits 1 modulo n is called the order. The formal defini-
tion is:
Definition (6.1). Let n > 1 and gcd (a, n) = 1. The order of a modulo n is the smallest pos-
itive integer k such that ak ≡ 1 (mod n).
From the above examples we have that the order of 4 (mod 13) is 6 and of
5 (mod 12) is 2.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T H E O R D ER O F A N I N T E G E R M O D U LO n (235–245) 237
Example 6.2
Solution
(a) We examine the powers of 5 modulo 6:
Proposition (6.2). If a ≡ b (mod n) then a and b (mod n) have the same order.
Proof.
Let k be the order of a modulo n. Therefore,
ak ≡ 1 (mod n) .
we have ak ≡ bk ≡ 1 (mod n). This k must be the smallest positive index of b such that
bk ≡ 1 (mod n) .
Why?
Because if there is a smaller integer, say m < k, such that bm ≡ am ≡ 1 (mod n) then m would
be the order of a modulo n. Hence k is the order of b modulo n.
In the definition of order, (6.1), why do we need the integers a and n to be relatively prime, that is
gcd (a, n) = 1?
We will see through using an example what happens when such integers aren’t relatively
prime. Let us consider a case where gcd (a, n) > 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
238 6 P R IM I TI VE R O OTS A N D I N D I C ES
Example 6.3
Solution
Substituting k = 1, 2, 3, 4 and 5 into 2k ≡ b (mod 6)
21 ≡ 2, 22 ≡ 4, 23 ≡ 2, 24 ≡ 4, 25 ≡ 2 (mod 6) .
We begin to see a pattern emerging in our results, namely that the residues are either 2 or 4 (mod 6).
Why do we only get 2 or 4 as the least positive residues in this case?
We can rewrite 2k ≡ 2 (2k−1 ) ≡ b ( mod 6). The gcd (2, 6) = 2 which implies that
Why?
Because of Proposition (3.15) of Chapter 3:
2k will always be an even residue. In fact, 2k ≢ 1 (mod 6) for any positive integer k.
We can generalize this because it is not just restricted to this case, as we’ll now prove.
Proposition (6.3). If gcd (a, n) > 1 then ak ≢ 1 (mod n) for any positive integer k.
By contradiction.
Proof.
Let g = gcd (a, n) > 1. Suppose there exists a positive integer k such that
ak ≡ 1 (mod n) . (∗)
By using the rules of indices we can rewrite ak = aak−1 . Rewriting (∗) gives
ak ≡ a (ak−1 ) ≡ 1 (mod n) .
Since g = gcd (a, n) > 1 and for this congruence to hold we must have g | 1.
Why?
T H E O R D ER O F A N I N T E G E R M O D U LO n (235–245) 239
If gcd (a, n) > 1 then a (mod n) has no order, or we say the order does not exist.
The order of 2 modulo 7 is 3. Note that the index in each case is a multiple of 3, that is
23m ≡ 1 (mod 7).
Similarly, the order of 2 modulo 13 is 12 (see Example 6.2 (b)) and we have:
212 ≡ 1 (mod 13) , 224 ≡ 1 (mod 13) , 236 ≡ 1 (mod 13) , 248 ≡ 1 (mod 13) .
Example 6.4
Solution
(i) We have 32 ≡ 9 ≡ 1 (mod 8).
Therefore, the order of 3 modulo 8 is 2 because the first index to give us 1 modulo 8 is 2. So
k = 2 and 3k ≡ 1 (mod 8).
(ii) Evaluating 32k gives
k k
32k ≡
⏟ (32 ) ≡
⏟ (1) ≡ 1 (mod 8) .
By rules of indices By part (i)
Can there be an index of 3 which is not a multiple of the order 2 yet is still congruent to 1 modulo 8?
No, and we will see why through the use of contradiction in our next proof. We will prove
that ah ≡ 1 (mod n) if and only if h is a multiple of the order k.
240 6 P R IM I TI VE R O OTS A N D I N D I C ES
Proof.
We are given that the order of a modulo n is k. This implies that
ah ≡ ak×m ≡ (ak ) m
⏟ ≡ (1) m
⏟ ≡ 1 (mod n).
By rules of indices By(∗)
Thus ah ≡ 1 (mod n), which is our required result for this part of the proof.
This ar ≡ 1 (mod n) is impossible because r is less than k, 0 < r < k, and k is the order of a
modulo n. Recall Definition (6.1):
The order of a modulo n is the smallest positive integer k such that ak ≡ 1 (mod n).
Our supposition that k does not divide h must be wrong, so k | h.
As we have seen throughout our investigations so far, number theory builds upon pre-
vious results. In the following corollary we establish a link between Euler’s totient function
described in the last chapter and the work we have been doing on the order of integers
modulo n.
Proof.
Let k be the order of a modulo n. Recall the order of a (mod n) only exists if gcd (a, n) = 1.
By Euler’s Theorem (5.14) of the last chapter we have:
a𝜙(n) ≡ 1 (mod n) .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T H E O R D ER O F A N I N T E G E R M O D U LO n (235–245) 241
Substituting h = 𝜙 (n) into the previous Proposition (6.4) gives k | 𝜙 (n), which is our re-
quired result.
To find the order of a modulo n we only need to examine the positive factors of the num-
ber 𝜙 (n). This means that we do not need to check each individual index a1 , a2 , ⋯ , a𝜙(n)
modulo n. This corollary makes the evaluation of the order much simpler.
Example 6.5
Solution
The integers 2 and 17 are relatively prime, so the order of 2 (mod 17) exists.
Since 17 is a prime number, so what is 𝜙 (17) equal to?
Applying 𝜙 (p) = p − 1, where p is prime, we have
𝜙 (17) = 17 − 1 = 16.
Hence the order of 2 modulo 17 is 8. Recall the order is the smallest positive index of 2 which gives
1 (mod 17).
Now let us tackle the problem stated at the start of this chapter where applying Euler’s
Theorem did not help.
Example 6.6
Solution
From the introduction we know we must find the least positive residue x such that
Recall we had 𝜙 (1000) = 400 and the prime decomposition of 400 = 24 × 52 . The positive factors of
400 are 1, 2, 4, 5, 8, 10, 16, 20, 25, 40, 50, 80, 100, 200, and 400. We only need to test these indices of
7 until we get 1 (mod 1000):
71 ≡ 7, 72 ≡ 49, 74 ≡ 401, 75 ≡ 807, 78 ≡ 801, 710 ≡ 249, 716 ≡ 601, 720 ≡ 1 (mod 1000) . (∗)
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
242 6 P R IM I TI VE R O OTS A N D I N D I C ES
Hence the order 7 (mod 1000) is 20. Writing the index of 311 as a multiple of 20 and any remainder
gives 311 = (15 × 20) + 11. Therefore, using the rules of indices and the results in (∗) we have
15
7311 ≡ 7(15×20)+11 ≡ (720 ) × 711 ≡ ⏟
1 ×711 ≡ 710 × 7 ≡ ⏟
249 ×7 ≡ 1743 ≡ 743 (mod 1000) .
By (∗) By (∗)
Note that using the order of 7 (mod 1000) makes the calculation much simpler.
Example 6.7
Solution
By Example 6.5 we know that the order of 2 modulo 17 is 8. This implies
Example 6.8
Show that 212m+r ≡ 2r (mod 13) where m and r are any positive integers.
Solution
By Example 6.2 (b) we know that the order of 2 modulo 13 is 12. Therefore,
T H E O R D ER O F A N I N T E G E R M O D U LO n (235–245) 243
We have
m
212m+r ≡
⏟ (212 ) × 2r ≡ (1) 2 r r
⏟ × 2 ≡ 2 (mod 13) .
By rules of indices By (†)
Say we want to find the least non-negative residue x such that 21000 ≡ x (mod 13), then we
can break the index 1000 into a multiple of 12 (order of 2 (mod 13)) and any remainder,
1000 = (83 × 12) + 4. Therefore, we have
Proof.
We are given that a modulo n has order k, so
ak ≡ 1 (mod n) . (∗∗)
j − m = ks where s is an integer.
a j ≡ am+ks
s
≡ am × (ak ) [Using the rules of indices]
≡ am × (1) s m
⏟ ≡ a (mod n) .
By (∗∗)
How?
By contradiction.
Suppose j ≢ m (mod k) which implies j − m ≠ kq [not equal].
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
244 6 P R IM I TI VE R O OTS A N D I N D I C ES
By (∗∗)
≡ a × ar (mod n).
m
am × ar ≡ a j ≡ am ≡ am × (1) (mod n) .
The gcd (a, n) = 1 which implies gcd (am , n) = 1, so applying the Cancellation Law (3.9):
if a × c ≡ b × c (mod n) and g = gcd (c, n) = 1 then a ≡ b (mod n),
But ar ≢ 1 (mod n) because r is greater than 0 and less than k, 0 < r < k. Recall k is the
order of a modulo n.
This means that we have a contradiction. Our supposition j ≢ m (mod k) must be wrong,
so j ≡ m (mod k), which is our required result.
Why?
Because we have
a j ≡ am ( mod n) ⇔ j ≡ m ( mod k).
So if j is a larger index than m and j ≡ m (mod k) then we only need to work out am in order
to find a j modulo n. This is demonstrated in the next example.
Example 6.9
Determine the least non-negative residue x such that 61 000 004 ≡ x (mod 17).
Solution
Since gcd (6, 17) = 1, so 6 (mod 17) has an order. As 17 is prime, so 𝜙 (17) = 16. The positive factors
of 16 are 1, 2, 4, 8, and 16, so we need to find
T H E O R D ER O F A N I N T E G E R M O D U LO n (235–245) 245
Actually we only need to evaluate 62 , 64 , 68 ≡ ? (mod 17) because we know 61 ≡ 6 (mod 17) and by
Euler’s Theorem, 616 ≡ 1 (mod 17). Evaluating the indices 2, 4, and 8 with base 6 gives:
2
62 ≡ 36 ≡ 2, 64 ≡ 22 ≡ 4, 68 ≡ (64 ) ≡ 42 ≡ 16 ≡ −1 (mod 17) . (†)
Since none of these is congruent to 1 modulo 17, so the order of 6 modulo 17 is 16. Let k be the order
of 6 modulo 17, so k = 16.
We use the previous Proposition (6.6),
to evaluate 61 000 004 ≡ x (mod 17). Applying this Proposition with k = 16 gives:
Summary
The order of a modulo n is the smallest positive index k such that ak ≡ 1 (mod n).
We can find the order k of a modulo n by using:
Corollary (6.5). Let the integer a modulo n have order k. Then k | 𝜙 (n); the order is a factor of 𝜙 (n).
EXERCISES 6.1
(Brief solutions at end of book. Full (c) 9 (mod 16) (d) 11 (mod 25)
solutions available at <http://www.oup.co. (e) 3 (mod 13)
uk/companion/NumberTheory>.)
3. Given that the order of 5 modulo 13 is
4, determine the least non-negative
1. Find the order of 2:
residue x such that 5101 ≡ x (mod 13).
(a) modulo 7 (b) modulo 11
(c) modulo 17 (d) modulo 23 4. Determine the order of 3 modulo 100.
Hence, or otherwise, find the last two
2. Determine the orders of the following:
digits of 31001 .
(a) 3 (mod 10) (b) 7 (mod 12)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
246 6 P R IM I TI VE R O OTS A N D I N D I C ES
5. Determine the order 7 modulo 60. 13. Prove that if a has order 2k modulo
Also find the inverse of 7 modulo 60 prime p where p is odd then
and solve the linear congruence ak ≡ −1 (mod p) .
7x ≡ 59 (mod 60) .
14. Let p be an odd prime and
6. Find the order of 5 modulo 21. a ≢ 1 (mod p). Show that the order of a
Hence, or otherwise, solve modulo pm divides pm − pm−1 .
5x ≡ 16 (mod 21) . 15. Let km be the order of a modulo n.
Show that k | 𝜙 (n).
7. In each of the following cases
determine the least non-negative 16. Prove that if a modulo n has order k
residue x: then so does the inverse of a modulo n
have order k.
(a) 31000 ≡ x (mod 17)
(b) 3970 ≡ x (mod 98) 17. Let 2 (mod p) where p is an odd prime
have order rs where s > 1. If
8. *Determine the last three digits
311 2r ≢ 1 (mod p), prove that
of 3 .
9. Let the order of a modulo n be k. Show 2r(s−1) + 2r(s−2) + 2r(s−3) + ⋯
that inverse of a modulo n is + 2r + 1 ≡ 0 (mod p) .
ak−1 (mod n) .
[Hint: 2rs − 1 = (2r − 1) (2r(s−1) +
10. Prove that if a modulo n has order mk 2r(s−2) + 2r(s−3) + ⋯ + 2r + 1).]
where m, k are positive integers then
am has order k. 18. Let a ≢ 1 (mod p) and a (mod p) have
order k. Prove that
11. Explain why a (mod 2) where a is odd
has order 1. ak−1 + ak−2 + ak−3 + ⋯ + 1 ≡
0 (mod p)
12. Let p be prime. If the order of a where p is prime.
modulo p is k, show that
19. *Let a modulo prime p have order 4.
4
k | (p − 1) . Show that (a + 1) ≡ −4 (mod p).
.........................................................................................................
So far, we have only found orders of some very low integers such as 2, 3, 6, … This is be-
cause finding ak involves tiresome calculations. In this section we establish a much simpler
procedure to find the order of a modulo n.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN D I C E S ( 2 4 6 – 2 5 3 ) 247
Example 6.10
Solution
(i) Since 3 and 7 are relatively prime, so the order of 3 modulo 7 exists. From the previous section we
have that the order k of a (mod n) satisfies k | 𝜙 (n) and in Chapter 5 we saw that if p is prime then
𝜙 (p) = p − 1. Since 7 is prime, so we have 𝜙 (7) = 7 − 1 = 6. Therefore, the order k of 3 modulo 7
must be a positive factor of 6. That is, k must equal one of 1, 2, 3, or 6:
31 ≡ 3, 32 ≡ 9 ≡ 2, 33 ≡ 27 ≡ 6, 36 ≡ 1 (mod 7) .
31 ≡ 3, 32 ≡ 2, 33 ≡ 6, 34 ≡ 81 ≡ 4, 35 ≡ 34 × 3 ≡ 4 × 3 ≡ 5 and 36 ≡ 1 (mod 7) .
36 ≡ 1(mod 7)
33 ≡ 6(mod 7)
Modulo 7
35 ≡ 5(mod 7) 32 ≡ 2(mod 7)
34 ≡ 4(mod 7) 31 ≡ 3(mod 7)
Figure 6.1 shows that the reduced residue system modulo 7 can be written as
3x ≡ r (mod 7) where r = 1, 2, 3, 4, 5, 6.
x
Note that 3 (mod 7) generates all the residues in the reduced residue system. All these
numbers 31 , 32 , ⋯ , 3k are incongruent modulo 7. (No two of them are congruent to each
other.) This is true for the general case:
Proposition (6.7). Let a (mod n) have order k. Then the integers a, a2 , ⋯ , ak are incongru-
ent modulo n.
Proof.
Suppose
a j ≡ am (mod n) where j, m ∈ {1, 2, 3, 4, ⋯ , k} .
Required to prove that j = m.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
248 6 P R IM I TI VE R O OTS A N D I N D I C ES
Example 6.11
Given that the order of 2 (mod 13) is 12, find the orders of the following modulo 13:
(i) 4 (ii) 8 (iii) 3 (iv) 11
Solution
We are given that the order of 2 modulo 13 is 12, which implies that
In our case a = 2, which has order 12. Applying this proposition means that
2, 22 , 23 , ⋯ , 212 (∗)
are incongruent modulo 13. (This is the reduced residue system modulo 13.) One of these numbers
in (∗) is congruent to 3 modulo 13 because 3 is in the reduced residue system modulo 13.
Which one?
We can determine this by trial and error:
IN D I C E S ( 2 4 6 – 2 5 3 ) 249
This implies that the order of 3 modulo 13 is the same as the order of 24 modulo 13. We are given that
212 ≡ 1 (mod 13). Rewriting the index 12 as a multiple of 4:
3 3
212 ≡ (24 ) ≡
⏟ (3) ≡ 1(mod 13).
By (†)
(iv) Again 11 is not a power of 2, so we use brute force to find which power of 2 gives 11(mod 13):
Since we have index 7 and this has no factor in common with 12 apart from 1, that is gcd (7, 12) = 1,
so we cannot write 12 as a multiple of 7.
How can we find the order of 11 modulo 13?
We are given 212 ≡ 1(mod 13), therefore by using the rules of indices we have
12 7 7
(27 ) ≡ (212 ) ≡ (1) ≡ 1 (mod 13).
The order of 27 is 12. We cannot find a smaller positive index which will give 1 modulo 13. Since
27 ≡ 11 (mod 13), so the order of 11 modulo 13 is 12.
We will show later (Corollary (6.9)) that if gcd (s, k) = 1 (that is s and k are relatively prime)
where k is the order of a then the order of as is also k.
Example 6.12
Determine the order of 3 (mod 50). Also find the remainder when 311002 is divided by 50.
Solution
Since the gcd (3, 50) = 1, so the order of 3 (mod 50) is a positive factor of 𝜙 (50) and
The positive factors of 20 are 1, 2, 4, 5, 10, and 20. Computing these indices (apart from 20) with base
3 gives
Notice how the computation is much easier by using the order of 3 (mod 50). Hence
311002 ≡ 11 (mod 50) says that 311002 divided by 50 leaves remainder 11.
The next proposition summarizes the above results and gives a much simpler technique for
evaluating the order of as .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
250 6 P R IM I TI VE R O OTS A N D I N D I C ES
k
Order Formula (6.8). Let a modulo n have order k. Then as (mod n) has order
gcd (s, k)
where s is a positive integer.
Proof.
We are given that a modulo n has order k. This implies that
ak ≡ 1 ( mod n). (†)
Let g = gcd (s, k). Then there exist integers x and y such that
gx = s and gy = k (∗)
y
where gcd (x, y) = 1. We examine (as ) :
(as ) ≡ (agx )
y k/g
[By (∗)]
k
≡ (ax ) [Using the rules of indices]
k x x
≡ (a ) ≡ (1)
⏟ ≡ 1 (mod n).
By(†)
Let as have order r. We need to prove that r = y because from (∗) we have
k k
y= = .
g gcd (s, k)
Showing y | r:
r
Since as has order r, then (as ) ≡ 1 (mod n) and by (†) we have ak ≡ 1 (mod n):
r
(as ) ≡ asr ≡ ak ≡ 1 (mod n) .
Again by the above Proposition (6.4) we have k | sr. Substituting gx = s and gy = k (these
are from (∗)) into k | sr gives
IN D I C E S ( 2 4 6 – 2 5 3 ) 251
We have both r | y and y | r, which implies that y = ±r because by Proposition (1.2) (d),
a|b and b | a ⇔ a = ±b.
y cannot be negative because gy = k and k is the order of a modulo n. Hence y = r which
k k
means the order of as is y = = . This is our required result.
g gcd (s, k)
Proof.
Apply the Order Formula (6.8) with gcd (s, k) = 1.
Example 6.13
Complete the following table which gives the orders of integers modulo 11 by evaluating the indices
to base 2.
Table 6.1
Integer j 1 2 3 4 5 6 7 8 9 10
Order of j (mod 11)
Solution
If j = 1 then the order of 1 is clearly 1 because 11 ≡ 1 (mod 11).
To establish the table of the order of the remaining integers we apply the Order Formula (6.8):
k
Order of as = where k is the order of a.
gcd (s, k)
We can use powers of a = 2. (Why use base 2 will be answered in the next section.)
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
252 6 P R IM I TI VE R O OTS A N D I N D I C ES
The integers 2 through to 10 can all be expressed as 2index modulo 11. For example, 2 ≡ 21 ≡ 2 (mod 11).
Also, by Euler’s Theorem we have 2𝜙(11) ≡ 210 ≡ 1 (mod 11).
So far, we have:
0(mod 11)
210 ≡ 1(mod 11)
21 ≡ 2(mod 11)
Modulo 11
We use the Order Formula (6.8) with base a = 2 and k = 10 to find the order of the remaining inte-
gers modulo 11:
The order of 22 ≡ 4 (mod 11) is
10 10
= =5 [Using (6.8) with s = 2 and k = 10] .
gcd (2, 10) 2
10 10
= = 10 [Using (6.8) with s = 3 and k = 10] .
gcd (3, 10) 1
10 10
= =5 [Using (6.8) with s = 4 and k = 10] .
gcd (4, 10) 2
10 10
= =2 [Using (6.8) with s = 5 and k = 10] .
gcd (5, 10) 5
10 10
= =5 [Using (6.8) with s = 6 and k = 10] .
gcd (6, 10) 2
10 10
= = 10 [Using (6.8) with s = 7 and k = 10] .
gcd (7, 10) 1
10 10
= =5 [Using (6.8) with s = 8 and k = 10] .
gcd (8, 10) 2
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN D I C E S ( 2 4 6 – 2 5 3 ) 253
10 10
= = 10 [Using (6.8) with s = 9 and k = 10] .
gcd (9, 10) 1
Table 6.2
Integer j 1 2 3 4 5 6 7 8 9 10
Order of j (mod 11) 1 10 5 5 5 10 10 10 5 2
Note from the bottom row of the table that the order of j (mod 11) is a positive factor of 𝜙 (11) = 10.
In this example we use indices to base 2 to generate all the integers given in the above
table.
Why?
Well 2 modulo 11 has order 𝜙 (11) = 10. We will show in the next section that if the order
of r (mod n) is 𝜙 (n) then the following
{r, r 2 , r 3 , ⋯ , r 𝜙(n) }
gives a reduced residue system modulo n (see Proposition (6.11) given in the next section).
Such an r is called a primitive root of n. More on this in the next section.
Summary
k
Let a modulo n have order k. Then the integer as where s is a positive integer has order .
gcd (s, k)
EXERCISES 6.2
(Brief solutions at end of book. Full 3. Determine the order of the following
solutions available at <http://www.oup.co. integers modulo 2520:
uk/companion/NumberTheory>.)
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 (mod 2520) .
1. Find the order of the following:
(a) 1 (mod 5) (b) 2 (mod 5) 4. Determine the following:
(c) 3 (mod 5) (d) 4 (mod 5)
31 , 32 , 33 , ⋯ , 3𝜙(17) (mod 17) .
2. Determine the order of the following:
(a) 2 (mod 11) (b) 3 (mod 11) What do you notice about the resulting
(c) 5 (mod 11) (d) 7 (mod 11) residues?
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
254 6 P R IM I TI VE R O OTS A N D I N D I C ES
8. State the number of integers which have (b) Determine the order of
an order modulo n for
81 (mod 106) .
(a) n = 20 (b) n = 200
(c) n = 2000 (d) n = 20 000 15. Determine the least positive index x
such that 4x − 1 is divisible by 83.
9. (a) Show that the order of 1 (mod n)
is 1. 16. *Find the order of 2 (mod 1001).
.........................................................................................................
T H E O RY O F I N D I C E S ( 2 5 4 – 2 6 6 ) 255
Definition (6.10). If a (mod n) has order 𝜙 (n) then a is called a primitive root modulo n
or just a primitive root of n.
The first time aindex is congruent to 1 modulo n is when the index is the number 𝜙 (n). For
example, 2 is a primitive root of 11 because
21 ≡ 2, 22 ≡ 4, 23 ≡ 8, 24 ≡ 5, … , 29 ≡ 6 and 210 ≡ 1(mod 11).
Recall 𝜙 (11) = 10; the first index of 2 which is congruent to 1 (mod 11) is 10:
0(mod 11)
25 ≡ 10(mod 11)
210 ≡ (1mod 11)
27 ≡ 7(mod 11)
22 ≡ 4(mod 11)
29 ≡ 6(mod 11)
24 ≡ 5(mod 11)
Note that 2, 22 , ⋯, 2𝜙(11) covers a reduced residue system (mod 11) in some order.
Another example is that 2 is a primitive root of the prime 101. This means that the 100
numbers in
{2, 22 , 23 , ⋯ , 299 , 2100 } are congruent to {1, 2, 3, ⋯ , 99, 100} in some order.
In the next section we will show that every prime has a primitive root.
In Section 6.5 (website material) we will show that the integers n = 2, 4, pk , 2pk where p
is an odd prime have primitive roots.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
256 6 P R IM I TI VE R O OTS A N D I N D I C ES
Example 6.14
Solution
The integer 7 is prime so 𝜙 (7) = 7 − 1 = 6. The positive divisors of 6 are 1, 2, 3, and 6. Evaluating
these indices to the base 3 yields:
31 ≡ 3, 32 ≡ 2, 33 ≡ 6 and 36 ≡ 1 (mod 7) .
Example 6.15
Solution
Since 23 ≡ 1 (mod 7), so the order of 2 modulo 7 is 3 and not 6 which means 2 is not a primitive root
of 7.
Proposition (6.11). Let gcd (r, n) = 1 and r1 , r2 , r3 , ⋯ , r𝜙(n) be integers relatively prime to
n. If r is a primitive root of n, then
r, r 2 , r 3 , ⋯ , r 𝜙(n)
Proof.
See Exercises 6.3, question 20. These rj ’s where 1 ≤ j ≤ 𝜙 (n) are the reduced residue system
modulo n because gcd (rj , n) = 1.
Let r be a primitive root of n. By the previous Proposition (6.11) we have that the first 𝜙 (n)
powers of r,
r, r 2 , r 3 , ⋯ and r 𝜙(n) ,
are congruent in some order to those residues in the reduced residue system.
From Example 6.14 we have seen that r = 3 is a primitive root of 7; the powers of 3 modulo
7 are:
31 ≡ 3, 32 ≡ 2, 33 ≡ 6, 34 ≡ 4, 35 ≡ 5 and 36 ≡ 1 (mod 7) . (†)
This set {1, 2, 3, 4, 5, 6} is the reduced system modulo 7 and each of these numbers in this
set are congruent to 3index modulo 7.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
T H E O RY O F I N D I C E S ( 2 5 4 – 2 6 6 ) 257
In general, if a is an arbitrary residue belonging to the reduced residue system then this
residue a can be expressed as
a ≡ r k (mod n)
for an index k where 1 ≤ k ≤ 𝜙 (n) and r is a primitive root of n.
Example 6.16
Given that 3 is a primitive root of 89, find the value of k such that 3k ≡ 81 (mod 89).
Solution
We have 34 ≡ 81 (mod 89), therefore k = 4.
k = 4 is called the index of 81 relative to 3 and normally denoted by ind3 (81) = 4 be-
cause
34 ≡ 81 (mod 89) .
We write the formal definition of index as follows:
Definition (6.12). Let r be a primitive root modulo n. If the gcd (a, n) = 1, then the smallest
positive index k such that
r k ≡ a (mod n)
is called the index of a relative to r. This k is denoted by indr (a) or just ind (a).
This definition says that if the number a is in the reduced residue system modulo n then
we can express it as a power of a primitive root of n.
Since r is a primitive root of n, so 1 ≤ indr (a) ≤ 𝜙 (n) (see Exercises 6.3, question 15). We
have k = indr (a), so the above definition can be written as:
Example 6.17
Show that 2 is a primitive root of 5. Find the following with respect to modulo 5:
(a) ind2 (1) (b) ind2 (2) (c) ind2 (3) (d) ind2 (4) (e) ind2 (17)
Solution
Evaluating the powers of 2 we have
258 6 P R IM I TI VE R O OTS A N D I N D I C ES
ind2 (17) = 1.
17 ≡ 2 ≡ 21 (mod 5) .
In Proposition (6.15) we will show that if a ≡ b (mod n) then indr (a) = indr (b).
Example 6.18
Show that 3 is a primitive root of 5. Find the following with respect to modulo 5:
(a) ind3 (1) (b) ind3 (2) (c) ind3 (3) (d) ind3 (4) (e) ind3 (18)
Solution
Evaluating the powers of 3, we have
In this subsection we prove some of the rules of indices and you will notice that they are
analogous to the rules of logs in algebra, except that the base is a primitive root.
From the previous two examples we have
T H E O RY O F I N D I C E S ( 2 5 4 – 2 6 6 ) 259
We have already seen this in Examples 6.17 (e) and 6.18 (e):
Proof.
We use the definition of the index given in (6.13):
This implies that indr (a) = indr (b), which is our required result.
Proposition (6.16). Let r be a primitive root of n and indr (a) be the index of a relative to r.
Then we have the following results:
(a) indr (ab) ≡ indr (a) + indr (b) (mod 𝜙 (n))
(b) indr (ak ) ≡ k indr (a) (mod 𝜙 (n))
(c) indr (1) ≡ 0 (mod 𝜙 (n)) and indr (r) ≡ 1 (mod 𝜙 (n)).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
260 6 P R IM I TI VE R O OTS A N D I N D I C ES
Proof.
(a) Using the ordinary rules of indices, we have
r indr (a)+indr (b) = r indr (a) r indr (b) .
Applying Definition (6.13) on this,
r indr (a) ≡ a (mod n) and r indr (b) ≡ b (mod n).
Multiplying these two results and using the rules of indices gives
r indr (a)+indr (b) ≡ r indr (a) r indr (b) ≡ ab (mod n).
Using Definition (6.13) on indr (ab) gives
Equating these results, r indr (a)+indr (b) ≡ ab ( mod n) and r indr (ab) ≡ ab (mod n), we have
Recall r is a primitive root, so the order of r is 𝜙 (n). This is our required result.
(b) We need to prove indr (ak ) ≡ k indr (a) (mod 𝜙(n)).
Again, applying the definition of the index (6.13),
T H E O RY O F I N D I C E S ( 2 5 4 – 2 6 6 ) 261
We have r indr (a) ≡ a (mod n). Taking this to the power k yields
k
(r indr (a) ) ≡ ak (mod n)
r k indr (a) ≡ ak (mod n). (∗∗)
We have solved linear congruences in Chapter 3, but in this section we solve non-linear
congruences where the index of the unknown is greater than 1.
We want to solve congruences of the type
xd ≡ a (mod n) (†)
How?
By using the rules of indices that we’ve just established. By these rules we have
262 6 P R IM I TI VE R O OTS A N D I N D I C ES
implies that if g | ind (a) where g = gcd (d, 𝜙 (n)) then there are exactly g incongruent so-
lutions. If g does not divide ind (a) then this equation has no solutions, which implies that
the initial equation (†) has no solutions.
We can illustrate this as:
Example 6.19
Solution
We want to use a small base to solve the given congruence. We need to first find a primitive root of
13 so that we can use the rules of indices that were established. The following evaluation shows that 2
is a primitive root modulo 13. (We can avoid all this computation, but it will help in solving the given
equation.)
We confirm that 2 is a primitive root of 13, since gcd (2, 13) = 1, 𝜙 (13) = 12, and the first index of 2
to give 1 (mod 13) is 12.
We create the table of indices based on these results:
Table 6.3
a 1 2 3 4 5 6 7 8 9 10 11 12
ind2 (a) 12 1 4 2 9 5 11 3 8 10 7 6
By Proposition (6.15):
a ≡ b ( mod n) implies indr (a) = indr (b) .
Applying this to the given equation 7x6 ≡ 6 (mod 13) with r = 2 yields
T H E O RY O F I N D I C E S ( 2 5 4 – 2 6 6 ) 263
Since 13 is prime, so 𝜙 (13) = 12. Applying these rules to ind2 (7x6 ) = ind2 (6) yields:
By locating 6 and 7 in the top row of Table 6.3 and reading the corresponding entries in the bottom
row, we have ind2 (7) = 11 and ind2 (6) = 5. Substituting these into (∗) gives
Let g = gcd (6, 12) = 6, therefore simplifying this 6 ind2 (x) ≡ 6 (mod 12) gives
6 6 12
ind2 (x) ≡ (mod ) ⇒ ind2 (x) ≡ 1 (mod 2) .
6 6 6
Recall ind2 (x) ≡ 1 (mod 2) means ind2 (x) is one more than a multiple of 2; ind2 (x) = 1 + 2k where k is
an integer. Since g = 6 and 6 | 6, so we have six incongruent solutions. Substituting k = 0, 1, 2, 3, 4 5
into this ind2 (x) = 1 + 2k gives us
Locating these residues in the bottom row of Table 6.3 and reading off corresponding entries in the
top row yields
x ≡ 2, 8, 6, 11, 5, 7 (mod 13).
You may like to check that each of these solutions x ≡ 2, 5, 6, 7, 8, 11 (mod 13) satisfies the given
7x6 ≡ 6 (mod 13). Checking that x ≡ 2 (mod 13) works:
Recall the given congruence 7x6 ≡ 6 (mod 13) means 7x6 is 6 more than a multiple of 13,
that is 7x6 = 6 + 13y, which is a non-linear Diophantine equation. Substituting the solution
x = 2 into this gives
448 − 6
7 × 26 = 448 = 6 + 13y which implies y= = 34.
13
Hence one solution to 7x6 = 6 + 13y is x = 2, y = 34. You are asked to find other solutions
in Exercises 6.3, question 16, where you will see that choosing a different primitive root of
13 will give the same solutions.
Example 6.20
8x ≡ 5 (mod 13) .
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
264 6 P R IM I TI VE R O OTS A N D I N D I C ES
Solution
Applying the rules of indices to 8x ≡ 5 (mod 13) gives the linear form
Since we are using the same primitive root and modulo, so we can use the same Table 6.3 as the
previous example. Using Table 6.3 to find ind2 (8) and ind2 (5) gives
Again the gcd (3, 12) = 3 and 3 | 9, which implies we have three incongruent solutions.
Simplifying the above equation 3x ≡ 9 (mod 12) yields
8x ≡ 5 (mod 13) .
Proposition (6.17). Let n have a primitive root and a and n be relatively prime. The
congruence
xm ≡ a (mod n)
has a solution ⇔ a𝜙(n)/g ≡ 1 (mod n) where g = gcd (m, 𝜙 (n)). Additionally, there are
exactly g incongruent solutions.
Proof.
See Exercises 6.3, question 21.
Example 6.21
12/4 3
1212/4 ≡ (−1) ≡ (−1) ≡ −1 (mod 13) .
T H E O RY O F I N D I C E S ( 2 5 4 – 2 6 6 ) 265
You can actually show this non-linear congruence x 4 ≡ 12 (mod 13) has no solutions by
using Table 6.3 of Example 6.19:
4 ind2 (x) ≡ ind2 (12) (mod 12) ⇒ 4 ind2 (x) ≡ 6 (mod 12) .
The gcd (4, 12) = 4 and 4 6, so there are no solutions to x 4 ≡ 12 (mod 13). However,
the advantage of the previous Proposition (6.17) is that we don’t have to form a table of
values, as we know from the outset whether the given congruence has solutions.
Example 6.22
Solution
From the previous example we have 12 ≡ −1 (mod 13), 𝜙 (13) = 12, and g = gcd (3, 12) = 3.
Substituting a = −1 into Proposition (6.17) we have
12/3 4
(−1) ≡ (−1) ≡ 1 (mod 13) .
The given equation x3 ≡ 12 (mod 13) has solutions, and taking indices we have
3 ind2 (x) ≡ ind2 (12) (mod 12) [Converting to linear form].
Using Table 6.3 of Example 6.19 on 3 ind2 (x) ≡ ind2 (12) (mod 12) we have
Summary
We use the following rules of indices to solve non-linear congruences:
266 6 P R IM I TI VE R O OTS A N D I N D I C ES
EXERCISES 6.3
(Brief solutions at end of book. Full the least non-negative residue x such
solutions available at <http://www.oup.co. that
uk/companion/NumberTheory>.) 7100 6100 ≡ x (mod 17).
1. Determine which of the following 10. Use this table of the primitive root 2 of
numbers are a primitive root of 7: 13 to answer the questions below.
(a) 3 (b) 5 a 1 2 3 4 5 6 7 8 9 10 11 12
2. Determine which of the following ind2 (a) 12 1 4 2 9 5 11 3 8 10 7 6
I N TE G ER S WI T H P R I M I T I V E R O OTS ( 2 6 7 – 2 7 6 ) 267
15. (a) Let r be a primitive root modulo n. 19. Let p be prime and gcd (a, p) = 1.
Show that if a and n are relatively Prove that xm ≡ a(mod p) has a
prime then 1 ≤ indr (a) ≤ 𝜙 (n) . p−1
solution ⇔ a g ≡ 1(mod p) where
(b) Prove Proposition (6.16) (c). g = gcd (m, p − 1).
16. Show that 7 is a primitive root and use 20. Prove Proposition (6.11).
this to solve 7x6 ≡ 6 ( mod 13). Also
find solutions to the non-linear 21. *Prove Proposition (6.17).
Diophantine equation 7x6 = 6 + 13y. 22. *Let p be an odd prime and have a
17. Solve x 14
≡ 27 (mod 37) by using the primitive root. Show that
primitive root 2 of modulo 37. (a) x2 ≡ −1(mod p) has solutions
18. Let r be a primitive root of an odd ⇔ p ≡ 1(mod 4).
prime p. Prove that 4
(b) x ≡ −1(mod p) has solutions
p−1
indr (p − 1) = . ⇔ p ≡ 1(mod 8).
2
.........................................................................................................
We might not have realized from the last section, but not all integers have primitive roots.
In this section we examine which integers do have primitive roots.
Example 6.23
Solution
In Example 6.19 from the previous section we showed that 2 is a primitive root modulo 13. How can
we find if there are other primitive roots modulo 13?
By Corollary (6.9):
Let a modulo n have order k. Then as has order k ⇔ gcd (s, k) = 1.
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
268 6 P R IM I TI VE R O OTS A N D I N D I C ES
The integer 2 modulo 13 has order k = 𝜙 (13) =12 because 2 is a primitive root. The integers which
are relatively prime to k =12 are s = 1, 5, 7, and 11. So the primitive roots are given by 2s because they
will have the same order as k = 12 by the above corollary:
This example demonstrates that if we can find one primitive root of a prime modulo then
we can find the others by using the above Corollary (6.9).
Next, we state the general case.
Proposition (6.18). Let r be a primitive root modulo p where p is prime. Then r m (mod p)
is also a primitive root modulo p, provided gcd (m, p − 1) = 1.
Proof.
See Exercises 6.4, question 7.
Example 6.24
Solution
First we need to find one primitive root modulo 19. From Exercises 6.3, question 7 we have that 2 is a
primitive root modulo 19.
As 19 is prime, so 𝜙 (19) = 18. Therefore, the order of 2 modulo 19 is 18.
Which natural numbers up to 18 are relatively prime to 18?
There are going to be 𝜙 (18) = 𝜙 (2) × 𝜙 (9) = 1 × (9 − 3) = 6 of these and they are
By the previous Proposition (6.18), the primitive roots are given by these numbers as indices to the
base 2:
Hence the primitive roots modulo 19 are 2, 3, 10, 13, 14, and 15.
We will show in the next chapter that using the Law of Quadratic Reciprocity, which
is one of the most powerful results of number theory, makes finding a primitive root of a
prime number easier.
I N TE G ER S WI T H P R I M I T I V E R O OTS ( 2 6 7 – 2 7 6 ) 269
x d ≡ 1 (mod p)
Proof.
See Exercises 6.4, question 18.
Example 6.25
Solution
How many solutions does the given congruence x5 ≡ 1 (mod 11) have?
By the previous Proposition (6.19):
Let d | (p − 1). The congruence x d ≡ 1 (mod p) has exactly d incongruent solutions.
We have 𝜙 (11) = 11 − 1 = 10 and 5 | 10, so we have five incongruent solutions modulo 11.
Next we find these five incongruent solutions. We test whether 2 is a primitive root modulo 11.
Evaluating the powers of 2 modulo 11 gives
21 ≡ 2, 22 ≡ 4, 23 ≡ 8, 24 ≡ 5, 25 ≡ 10, 26 ≡ 20 ≡ 9
27 ≡ 18 ≡ 7, 28 ≡ 14 ≡ 3, 29 ≡ 6, 210 ≡ 1 (mod 11) .
Hence 2 is a primitive root modulo 11. Creating the table for the primitive root 2 gives
Table 6.4
Integer a 1 2 3 4 5 6 7 8 9 10
ind2 (a) 10 1 8 2 4 9 7 3 6 5
Using the rules of indices to convert x5 ≡ 1 (mod 11) into linear form gives
From Table 6.4 we have ind2 (1) = 10. Substituting this ind2 (1) = 10 into (∗) yields
From this ind2 (x) ≡ 2 ≡ 0 (mod 2) we have ind2 (x) = 0 + 2k = 2k (even integer):
Locating these integers in the bottom row of the above Table 6.4 and reading off the corresponding
entries in the top row yields
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
270 6 P R IM I TI VE R O OTS A N D I N D I C ES
x ≡ 4, 5, 9, 3, 1 (mod 11).
Putting these into ascending order gives the five incongruent solutions
x ≡ 1, 3, 4, 5, 9 (mod 11).
Check that these solutions satisfy the given equation x5 ≡ 1(mod 11).
The given congruence x5 ≡ 1 (mod 11) implies that x5 is one more than a multiple of 11;
5
x = 1 + 11y, which is a non-linear Diophantine equation. Checking one of the solutions
found in the previous example, x ≡ 3 (mod 11), we have
In this subsection we prove that every prime has a primitive root. It is a challenging proof,
but we have broken it into smaller pieces to sweeten the pill.
Lemma (6.20). Let p be a prime number and d be a positive divisor of p − 1. The number
of positive integers less than p of order d modulo p is 0 or 𝜙 (d).
Proof.
For each divisor d of p − 1, let N (d) be the number of positive integers a such that
1 ≤ a ≤ p − 1 and the order of a modulo p is d.
We consider two cases:
Case I is where there is no integer of order d.
Case II is where there is an integer of order d.
Case I
If there is no integer of order d modulo p then clearly N (d) = 0. We have our required result
because N (d) = 0.
Case II
Let there be an integer a modulo p of order d. Then we have
ad ≡ 1 (mod p) . (†)
By Proposition (6.7):
Let a modulo n have order k. Then the integers a, a2 , ⋯ , ak are incongruent modulo n.
Therefore, a, a2 , a3 , ⋯ , ad are incongruent modulo p and these d integers are the solu-
tions of x d ≡ 1 (mod p).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N TE G ER S WI T H P R I M I T I V E R O OTS ( 2 6 7 – 2 7 6 ) 271
Why?
Example 6.26
This is Table 6.2 ( j is replaced by a) established in Example 6.13 giving the integer modulo 11 and its
order:
Integer a 1 2 3 4 5 6 7 8 9 10
Order of a (mod 11) 1 10 5 5 5 10 10 10 5 2
Find N (d) where N (d) is the number of positive integers a such that 1 ≤ a ≤ 𝜙 (11) and the order of
a (mod p) is d where d | (p − 1). Also determine ∑ N (d).
d | (p−1)
What do you notice about your result?
Solution
Since 11 is prime, so 𝜙 (11) = 10 and we use Corollary (6.5):
Let a modulo n have order k. Then k | 𝜙 (n).
The order of a (mod p) is a positive divisor of 𝜙 (11) = 10. (See bottom row of the above table.) The
positive divisors of 10 are 1, 2, 5, and 10.
From the bottom row of the above Table 6.2 we have
272 6 P R IM I TI VE R O OTS A N D I N D I C ES
Theorem (6.21). Let p be a prime number and d be a positive divisor of p − 1. There are
exactly 𝜙 (d) incongruent integers modulo p of order d.
Proof.
Let d be a positive divisor of p − 1 and N (d) denote the number of integers a such that
1 ≤ a ≤ p − 1 and the order of a modulo p is d.
By Corollary (6.5):
This implies that every integer a in 1 ≤ a ≤ p − 1 must have an order which is a positive
divisor of 𝜙 (p) = p − 1. Therefore, each of these a’s has an order d where d | (p − 1). Let
d1 , d2 , ⋯ , dk be the positive divisors of p − 1. By the previous Lemma (6.20) we have
∑ 𝜙 (d) = n.
d|n
∑ N (d) = ∑ 𝜙 (d) = p − 1.
d | (p−1) d | (p−1)
Why?
Because if N (dj ) = 0 rather than 𝜙 (dj ) then (∗) and (∗∗) would not equate.
Hence for a general positive divisor d of p − 1 we have N (d) = 𝜙 (d), so we have exactly
𝜙 (d) incongruent integers modulo p of order d.
This completes our proof.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N TE G ER S WI T H P R I M I T I V E R O OTS ( 2 6 7 – 2 7 6 ) 273
Primitive Root Theorem (6.22). Every prime p has a primitive root and there are 𝜙 (p − 1)
incongruent primitive roots.
Proof.
Apply the previous theorem with d = p − 1 because (p − 1) | (p − 1). Hence there are
𝜙 (p − 1) incongruent integers of order p − 1 modulo p. Therefore, there are 𝜙 (p − 1) ≥ 1
primitive roots of p.
Every prime has a primitive root and there are 𝜙 (p − 1) of them.
We can use a primitive root of prime moduli to prove some important results such as
Wilson’s Theorem (4.4) (see Exercises 6.4, question 20).
Summary
In this section we have proved that every prime has a primitive root and found all the incongruent
primitive roots modulo a prime.
EXERCISES 6.4
What do you notice about your result when What do you notice about your results?
d = 𝜙 (19)?
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
274 6 P R IM I TI VE R O OTS A N D I N D I C ES
∗
6. Let p be an odd prime. Prove that if 13. The integers 2, 3, 10, 13, 14, and 15 are
p r and r ≢ 1 (mod p) then the primitive roots modulo 19.
Determine the least non-negative
1 + r + r 2 + ⋯ + r p−3 + r p−2 ≡ 0 (mod p) . residue x in the product
If r ≡ 1(mod p), then determine the x ≡ 2 × 3 × 10 × 13 × 14 × 15 (mod 19) .
least non-negative residue x in
14. Let r be a primitive root modulo prime
1 + r + r 2 + ⋯ + r p−3 + r p−2 ≡ x (mod p) . p. Prove that the multiplicative inverse
of r (mod p) is also a primitive root
7. Prove Proposition (6.18).
modulo p.
8. Let r1 and r2 be incongruent primitive
roots modulo p where p is an odd 15. *Prove that the product of all the
prime. Show that r1 × r2 is not incongruent primitive roots of a prime
necessarily a primitive root p is congruent to 1 (mod p).
modulo p. 16. (i) Show that 3 is a primitive root
3
9. The incongruent primitive roots modulo F3 = 22 + 1 (F3 is a Fermat
modulo 19 are 2, 3, 10, 13, 14, and 15. prime).
Determine the order of (ii) Solve the quadratic congruence
(a) −2 (mod 19) x2 ≡ −1 (mod F3 ) .
(b) −3 (mod 19)
[The square roots of −1 (mod F3 ).]
(c) −10 (mod 19)
(d) −13 (mod 19) 17. (i) Show that 2 is a primitive root
(e) −14 (mod 19) modulo 243.
(f) −15 (mod 19) (ii) Solve the quadratic congruence
10. *Let p (be an odd prime) of the form x2 ≡ 82 (mod 243) .
p ≡ 3 (mod 4). Also let r be a primitive
root modulo p. Prove that −r has [Note 243 is composite.]
p−1 18. **Prove Proposition (6.19).
order .
2
11. The incongruent primitive roots [Hint: Use Lagrange’s Theorem:
modulo 17 are 3, 5, 6, 7, 10, 11, 12, Let
and 14.
P (x) = cm xm + cm−1 xm−1 + ⋯ + c1 x + c0
Determine the order of:
where cm ≢ 0 (mod p) and p is prime.
(a) −3 (mod 17)
(b) −5 (mod 17) Then polynomial congruence
(c) −6 (mod 17)
P (x) ≡ 0 (mod p)
(d) −7 (mod 17)
(e) −10 (mod 17) has at most m incongruent solutions.
(f) −11 (mod 17) We proved this (Lagrange) result in
(g) −12 (mod 17) Supplementary Problems 3,
(h) −14 (mod 17) question 3.23.]
12. *Let p be an odd prime of the form 19. Prove that the solutions a of FlT (4.1)
p ≡ 1(mod 4). Also let r be a primitive belong to the reduced residue system
root modulo p. Prove that −r is also a modulo p where p is prime:
primitive root of p.
If ap−1 ≡ 1 (mod p) then p a.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
I N TE G ER S WI T H P R I M I T I V E R O OTS ( 2 6 7 – 2 7 6 ) 275
∗
20. Prove Wilson’s Theorem (4.4) by (b) Show that the quadratic
using a primitive root of a prime: Diophantine equation x2 = r + 61y,
where r is a primitive root of 61, has no
If p is prime then
solutions.
(p − 1)! ≡ −1 (mod p).
(c) Show that the quadratic
21. Solve the non-linear Diophantine Diophantine equation x2 = r + py,
equation x6 = 1 + 13y. where p is an odd prime and r is a
22. (a) The prime 61 has 2 as a primitive primitive root, has no solutions.
root. Find all the primitive roots of 61.
.........................................................................................................
Supplementary Problems 6
276 6 P R IM I TI VE R O OTS A N D I N D I C ES
6.8. The integer 2 is the least primitive 6.15. Let a modulo n have order k. Show
root of the prime 19. that am has order k ⇔ gcd (k, m) = 1.
6.16. Let r be a primitive root of the prime
a 1 2 3 4 5 6 7 8 9 10 11
ind2 (a) 18 1 13 2 16 14 6 3 8 17 12 p. Prove that the least non-negative
residue of r m (mod p) is also a
a 12 13 14 15 16 17 18 primitive root of
ind2 (a) 15 5 7 11 4 10 9 p ⇔ gcd (m, p − 1) = 1.
6.17. Prove that if n has a primitive root
By using this table or otherwise,
then it has exactly 𝜙 (𝜙 (n))
determine the least non-negative
incongruent primitive roots.
residue x (mod 19) in each of the
following cases: 6.18. Let a > 1. Prove that if a has order
n − 1 modulo n then n is prime.
(a) x ≡ 5100 7100 8100 9100 (mod 19)
6.19. Solve x6 ≡ 11 (mod 19) and the
(b) x ≡ 111 000 001 151 000 003 181 000 007
Diophantine equation x6 = 11 + 19y.
(mod 19)
100 6.20. **Find a positive integer n which has
(c) x ≡ 5100 (mod 19)
100 100 no primitive roots.
[recall 5100 = 5(100 ) .]
6.21. Let the positive integers m and n have
[Hint: You may find the following
primitive roots. Show that mn does
result useful for part (c):
not necessarily have primitive roots.
10n ≡ 10 (mod 18) .]
6.22. *(i) Let r be an odd integer. Prove
m−2
6.9. Let a be a primitive root of p where p that r 2 ≡ 1 (mod 2m ) for m ≥ 3.
is prime. Show that
(ii) Prove that the integer 2m for
k
a ≢ 1 (mod p) m ≥ 3 has no primitive roots.
where 1 ≤ k < p − 1. 6.23. *Show that if m, n > 2 and
6.10. Determine the order of gcd (m, n) = 1 then the integer mn
10 modulo 18. has no primitive roots.
..............................................................................................................................
7 Quadratic Residues
..............................................................................................................................
7.1.1 Introduction
In Chapter 3 we solved linear congruences ax ≡ b (mod n), but in this chapter we test
whether the quadratic congruence x 2 ≡ a (mod p) where p is an odd prime has solutions.
If it does, then, by the definition of congruence, p (x 2 − a). We will use this to find the
prime factorization of integers such as x 2 + 1, x 2 − 2, x 2 − 3, ⋯.
If x 2 ≡ a (mod p) has a solution x, then we say x is the square root of a modulo p.
Equations of this type, x 2 ≡ a (mod p), are called quadratic congruences and are gener-
ally difficult to solve. For example, the solution to x 2 ≡ 2 (mod 127) could be any integer
1, 2, 3, …, 126 (mod 127) and we solve this in Example 7.5 later in this section. First, we
solve some simpler quadratic congruences.
Example 7.1
Solution
Let x = 1, 2, 3, ⋯ , 10. Tabulating and evaluating x 2 (mod 11):
Table 7.1
x 1 2 3 4 5 6 7 8 9 10
x 2 (mod 11) 1 4 9 5 3 3 5 9 4 1
Note that x 2 (mod 11) cannot take all the values 1, 2, ⋯ , 10 (mod 11). The congruence x 2 (mod 11)
can only be 1, 3, 4, 5, and 9 modulo 11, which are graphed in Figure 7.1.
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
278 7 Q UA DRATIC R E S I D U E S
x
1 2 3 4 5 6 7 8 9 10
Figure 7.1
Sketching the modulo 11 clock, we have that x 2 (mod 11) only stops at junctions 1, 3, 4, 5, and 9
modulo 11:
0(mod 11)
10(mod 11) 1(mod 11)
9(mod 11)
2(mod 11)
7(mod 11)
4(mod 11)
Hence x 2 (mod 11) will not stop at junctions 2, 6, 7, 8, and 10 modulo 11.
Why does x 2 (mod 11) only take values 1, 3, 4, 5, and 9 modulo 11?
2
Remember 10 ≡ −1 (mod 11) so 102 ≡ (−1) ≡ 1 (mod 11). Similarly,
2
9 ≡ −2 implies 92 ≡ (−2) ≡ 4 (mod 11)
2
8 ≡ −3 implies 82 ≡ (−3) ≡ 9 (mod 11)
2
7 ≡ −4 implies 72 ≡ (−4) ≡ 16 ≡ 5 (mod 11)
2
6 ≡ −5 implies 62 ≡ (−5) ≡ 25 ≡ 3 (mod 11) .
Note the symmetrical nature of the above graph and Table 7.1 (bottom row).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN T RO D U C T I O N TO Q UA D R AT I C R E S I D U E S ( 2 7 7 – 2 8 9 ) 279
We say 1, 3, 4, 5, and 9 are the quadratic residues of 11 and 2, 6, 7, 8, and 10 are the
quadratic non-residues of 11.
If a is a quadratic non-residue of p then the equation x 2 ≡ a (mod p) has no solution.
For most of this chapter we confine ourselves to modulo p where p is an odd prime.
The formal definition of quadratic residue is:
If the quadratic equation x 2 ≡ a (mod p) has no solution, then we say that a is a quadratic
non-residue of p.
Example 7.2
Solution
(i) Let x = 1, 2, 3, ⋯ , 6. Tabulating and evaluating x 2 (mod 7):
Table 7.2
x 1 2 3 4 5 6
x 2 (mod 7) 1 4 2 2 4 1
Hence x 2 ≡ 2 (mod 7) implies x ≡ 3 or 4 (mod 7). This means that the square roots of
2 (mod 7) are 3 or 4 (mod 7). This is represented graphically as follows:
x2 (mod 7)
5 Line of symmetry
2 x2 ≡ 2(mod 7)
x
1 2 3 4 5 6
Figure 7.3
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
280 7 Q UA DRATIC R E S I D U E S
By looking at the bottom row of this Table 7.3 we see that there is no x such that
x 2 ≡ 2 (mod 13).
Hence x 2 ≡ 2 (mod 13) has no solution which means there is no square root of 2 (mod 13).
Graphing these points gives:
12
10
8
6
4
2 x2 ≡ 2(mod 13)
x
1 2 3 4 5 6 7 8 9 10 11 12 13
Figure 7.4
Creating a table for p = 7, 11, or 13 is simple enough, but if p = 29 then we don’t want to
evaluate x 2 (mod 29) for x = 1, 2, 3, ⋯ , 28.
Is there a simpler way of deciding whether a given integer is a quadratic residue of 29?
Yes, as we will see in Example 7.3 later in this section. First note that we do not need to
evaluate all the residues
2
12 , 22 , 32 , ⋯ , (p − 1) (mod p) .
Why not?
2 2 2 2
Because (p − 1) ≡ (−1) ≡ 12 (mod p), (p − 2) ≡ (−2) ≡ 22 (mod p) , … and we have the
following general result:
2
Proposition (7.2). Let p be prime then (p − a) ≡ a2 (mod p).
Proof.
2 2
(p − a) ≡ (−a) ≡ a2 (mod p) .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN T RO D U C T I O N TO Q UA D R AT I C R E S I D U E S ( 2 7 7 – 2 8 9 ) 281
We can use this Proposition (7.2) to solve quadratic congruences; x 2 ≡ a (mod p).
Consider the congruence x 2 ≡ 4 (mod 29). Clearly x ≡ 2 (mod 29) is a solution to this.
By Proposition (7.2) we see that another solution is
x ≡ −2 ≡ 29 − 2 ≡ 27 (mod 29).
How many solutions does the general quadratic congruence x 2 ≡ a (mod p) have?
x 2 ≡ a (mod p)
Proof.
Let r be a primitive root of p. (We always have a primitive root of a prime p—see Primitive
Root Theorem (6.22) of the last chapter.)
Then taking indr of both sides of the given congruence x 2 ≡ a (mod p) yields
To convert this to linear form we use the rules of indices of Proposition (6.16) (b) in the last
chapter:
indr (b k ) ≡ k × indr (b) (mod 𝜙 (n)).
Applying this to the above congruence indr (x 2 ) ≡ indr (a) (mod p − 1) gives
This proposition means that if the square root of a (mod p) exists then it will have exactly
two square roots. Note that we must have an odd prime modulo p, as this result does not
hold for composite moduli. For example
282 7 Q UA DRATIC R E S I D U E S
1 2
1 2 3 5
1 3 3 6 4 6
2 5 4 7 9 7
4 6 5 8 10 8
9 10 12 11
For all these examples the split between quadratic and quadratic non-residues of p is half
p−1
and half. That is, there are quadratic residues and the same number of quadratic
2
non-residues. This means that for half the residues we can find square roots and for the
other half we cannot.
This is always the case for an odd prime. Next, we prove this for the general case.
p−1
Proposition (7.4). Let p be an odd prime. Then there are exactly quadratic residues
2
p−1
and quadratic non-residues of p.
2
Proof.
Consider the quadratic congruence x 2 ≡ a (mod p).
Let r be a primitive root modulo p. Applying the rules of indices of Chapter 6 we have
Then, by the proof of the previous Proposition (7.3), we have that this congruence,
2 indr (x) ≡ indr (a) (mod p − 1), only has solutions provided 2 indr (a). This means that
we only have solutions if indr (a) is even.
By Exercises 6.3, question 15 (a):
we have that indr (a) goes through all the integers 1, 2, 3, ⋯ , p − 1 and there are exactly
p−1 p−1
even numbers in this list. Hence there are exactly quadratic residues of p.
2 2
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN T RO D U C T I O N TO Q UA D R AT I C R E S I D U E S ( 2 7 7 – 2 8 9 ) 283
p−1 p−1
Similarly, there are odd numbers in the list 1, 2, 3, ⋯ , p − 1, so there are
2 2
quadratic non-residues of p.
101 − 1 503 − 1
For example, 101 has = 50 quadratic residues and 503 has = 251
2 2
quadratic residues. Note that both 101 and 503 are primes.
The previous Proposition (7.4) gives us the number of quadratic residues of p, but not the
actual residues themselves. We need a way to check whether a given integer is a quadratic
residue of p. The next theorem gives us a method for testing whether a given integer is a
quadratic residue of p or not.
Proof.
We have an if and only if, ⇔, so we need to prove this both ways.
p−1
(⇒). Let a be a quadratic residue of p. We need to prove a 2 ≡ 1 (mod p).
By the definition of quadratic residue, there is a solution x to the congruence
x 2 ≡ a (mod p) .
p−1
Taking this congruence x 2 ≡ a (mod p) to the power yields
2
p−1 p−1
(x 2 ) 2 ≡
⏟ xp−1 ≡ a 2 (mod p) . (∗)
By the rules of indices
We have p x.
Why?
x 2 ≡ a ≡ 0 (mod p) implies p a.
284 7 Q UA DRATIC R E S I D U E S
p−1
(⇐). For this part we assume a 2 ≡ 1 (mod p). We need to prove that a is a quadratic
residue of p. This means we need to find an x such that x 2 ≡ a (mod p).
Let r be a primitive root of p. Since r is a primitive root, so there is an integer k such that
r k ≡ a (mod p) . (†)
p−1
Raising this congruence to the power gives
2
p−1 k(p−1) p−1
(r k ) 2
≡
⏟ r 2 ≡a 2 ≡ 1 (mod p) .
By rules of indices
Now we use this result (7.5) to test whether various integers are quadratic residues of 29.
Example 7.3
Determine whether the following integers are quadratic residues of prime 29:
(a) 2 (b) 5 (c) 28 (d) 11
Solution
In each case we apply Euler’s Criterion (7.5) with p = 29:
p−1
a is a quadratic residue of p ⇔ a 2 ≡ 1 (mod p).
p − 1 29 − 1
We have = = 14.
2 2
29−1
(a) In this case let a = 2 and find x such that 2 2 ≡ 214 ≡ x (mod 29). Evaluating a lower index
of 2:
25 ≡ 32 ≡ 3 (mod 29).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN T RO D U C T I O N TO Q UA D R AT I C R E S I D U E S ( 2 7 7 – 2 8 9 ) 285
We use this to evaluate 214 . Writing the index 14 as a multiple of 5 plus any remainder,
14 = (2 × 5) + 4. Therefore,
2
214 ≡ 2(2×5)+4 ≡ (25 ) × 24 [By the rules of indices]
≡
⏟ 32 × 16 ≡ 144 ≡ 28 ≡ −1 (mod 29).
From above
3 3
56 ≡ (52 ) ≡ (−4) ≡ −6 (mod 29).
We have 1114 ≡ 1112 × 112 ≡ −6 × 5 ≡ −30 ≡ −1 (mod 29). Hence 11 is a quadratic non-
residue of 29 because 1114 ≡ −1 ≢ 1 (mod 29).
It means that we have solutions to the following congruences: x 2 ≡ 5, 28 (mod 29). This
implies the square roots of 5 and 28 (mod 29) exist.
Also, in the above example we showed that 2 and 11 are quadratic non-residues of 29.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
286 7 Q UA DRATIC R E S I D U E S
The square roots of 2 (mod 29) and 11 (mod 29) do not exist.
p−1
You may have noticed from the previous example that a 2 ≡ 1 or −1 (mod p). This is
always the case.
Proof.
See Exercises 7.1, question 9.
Euler’s Criterion does not give us the square roots, but it does tell us which residues do
have square roots. Finding square roots in modular arithmetic is no easy task unless we are
dealing with small moduli, as you will see in Example 7.4 below.
Example 7.4
Solution
(a) We first use Euler’s Criterion (7.5) to test whether 12 is a quadratic residue:
p−1
a is a quadratic residue of p ⇔ a 2 ≡ 1 (mod p).
Our prime p = 13 and we take a = 12 in this case. Therefore,
13−1
6
12 2 ≡ 126 ≡ (−1) ≡ 1 (mod 13) [Because 12 ≡ −1 (mod 13)].
IN T RO D U C T I O N TO Q UA D R AT I C R E S I D U E S ( 2 7 7 – 2 8 9 ) 287
Hence x ≡ 5 (mod 13) is one solution. We need to find the other solution which cannot be congru-
ent to 5 modulo 13, because we have two incongruent solutions.
By Proposition (3.14) (b):
a2 ≡ b2 (mod p) ⇔ a ≡ ±b (mod p) .
x ≡ −5 ≡ 8 (mod 13) .
Our two solutions are x ≡ 5 (mod 13) and x ≡ 8 (mod 13) [or x ≡ ±5 (mod 13)].
(b) Now we need to solve x 2 ≡ 2 (mod 13).
Since 26 ≡ −1 ≢ 1 (mod 13), so 2 is a quadratic non-residue of 13. This means that the given
quadratic congruence x 2 ≡ 2 (mod 13) has no solutions. (We showed this in Example 7.2 (ii) by eval-
uating each of the residues. Note it is much easier to use Euler’s Criterion.)
(c) We are required to solve x 2 + 4x + 5 ≡ 0 (mod 13).
How?
We first complete the square on the quadratic. (See Introductory Chapter for completing the square.)
Completing the square on the given quadratic:
2
x 2 + 4x + 5 = ⏟⎵
x2 + + 4 +1 = (x + 2) + 1 ≡ 0 (mod 13) .
4x⎵⏟
⎵⏟⎵
2
=(x+2)
2
Subtracting 1 from both sides gives (x + 2) ≡ −1 (mod 13).
Let y = x + 2, then we have the equation y 2 ≡ −1 (mod 13).
Remember −1 ≡ 12 (mod 13) and we have solved this in (a). Using the solutions y ≡ 5 (mod 13)
and y ≡ 8 (mod 13) of part (a), we have
Note that in the above example we can solve x 2 ≡ −1 (mod 13) but not x 2 ≡ 2 (mod 13).
This means that the square roots of −1 modulo 13 are 5 and 8 modulo 13. However, the
square root of 2 modulo 13 does not exist.
Compare these results with real numbers. We can find the square root of 2 but not the
square root of −1 in real numbers.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
288 7 Q UA DRATIC R E S I D U E S
Finding square roots of a (mod p) is a difficult task for larger moduli because it is im-
practical to trial all the integers from 1 to (p − 1) /2. We did use a primitive root in the last
chapter to solve quadratic congruences (see questions 14 and 17 of Exercises 6.3 and 6.4
respectively). We also have the following result:
If a is a quadratic residue of p where p ≡ 3 (mod 4) then the quadratic congruence
x 2 ≡ a (mod p) has the solutions given by
p+1
x ≡ ±a 4 (mod p) .
x 2 ≡ 2 (mod 127) .
Example 7.5
Solution
To find the square root of 2 (mod 127) we need to solve x 2 ≡ 2 (mod 127). This is more difficult to solve
because we have modulo 127 and it is not practical to trial all the integers from 1 to (127 − 1) /2 = 63.
First, note that 127 ≡ 3 (mod 4) so we can use the above formula.
By applying Euler’s Criterion we can show that 2 is a quadratic residue of 127, so x 2 ≡ 2 (mod 127)
p+1
has solutions. Substituting a = 2 into the above formula x ≡ ±a 4 (mod p) gives
127+1
x ≡ ±2 4 ≡ ±232 (mod 127) .
Now 27 ≡ 128 ≡ 1 (mod 127). Using this result to write the index 32 we have
4
x ≡ ±232 ≡
⏟ ± [27×4 × 24 ] ≡ ± [(27 ) × 16] ≡
⏟ ± [14 × 16] ≡ ±16 (mod 127) .
By the rules of indices 27 ≡1(mod 127)
Therefore, our solutions to x 2 ≡ 2 (mod 127) are x ≡ 16, −16 ≡ 16, 111 (mod 127).
x 2 − 2 162 − 2 1112 − 2
y= = , = 2, 97.
127 127 127
Hence two solutions to x 2 − 127y = 2 are x = 16, y = 2 and x = 111, y = 97.
1
https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm.
2
The Joy of Factoring by Samuel Wagstaff, page 45.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
IN T RO D U C T I O N TO Q UA D R AT I C R E S I D U E S ( 2 7 7 – 2 8 9 ) 289
Summary
Integer a is a quadratic residue of p if x 2 ≡ a (mod p) has solutions, otherwise a is a quadratic
non-residue of p. The quadratic x 2 ≡ a (mod p) only has solutions for half the integers a in
{1, 2, ⋯ , p − 1}.
EXERCISES 7.1
290 7 Q UA DRATIC R E S I D U E S
11. Prove the following results for an odd 12. *Prove that if a is a quadratic residue
prime p: of p where p ≡ 3 (mod 4) then the
quadratic congruence x 2 ≡ a (mod p)
(a) The product of two quadratic p+1
non-residues of p is a quadratic residue has the solutions x ≡ ±a 4 (mod p).
of p. Solve the following quadratic
congruences (all moduli are prime):
(b) The product of a quadratic residue
and quadratic non-residue of p is a (a) x 2 ≡ 3 (mod 83)
quadratic non-residue. *(b) x 2 ≡ 2 (mod (213 − 1))
(c) x 2 ≡ 5 (mod 127)
(c) The square of a quadratic residue
of p is a quadratic residue. 13. Prove that the multiplicative inverse of
a quadratic residue of p is also a
quadratic residue of p.
.........................................................................................................
TH E L E G E N D R E SY M B O L ( 2 9 0 – 3 0 0 ) 291
How can we find whether the quadratic congruence x 2 ≡ 48 (mod 79) has solutions?
Definition (7.7). Let p be an odd prime and a be any integer that is not divisible by p, that
a
is p a. The Legendre symbol ( ), also denoted (a/p), is given by
p
a 1 if a is a quadratic residue of p
( )={
p −1 if a is a quadratic non-residue of p
This notation is shorthand, but maybe it should carry a word of caution. The Legendre
symbol does not mean ‘a divided by p’, but is just a way of quickly denoting that the square
a
root of a(mod p) does or does not exist. If it does exist, then ( ) = 1, and if it does not then
p
a
we write ( ) = −1.
p
From the results of the last section we have the following illustration by using the Legen-
dre symbol on the primes p = 7, 11, and 13:
If p = 7 we have:
3 5 6
= = = –1
1 2 4 1 7 7 7
= = =1 3
7 7 7 2 5
4 6
Quadratic Quadratic
residues non-residues
Figure 7.7 (a)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
292 7 Q UA DRATIC R E S I D U E S
If p = 11 we have:
1 2
1 3 4 5 9 3 6
= = = = =1 2 6 7 8 10
11 11 11 11 11 4 7 = = = = = –1
5 8 11 11 11 11 11
9 10
Quadratic Quadratic
residues non-residues
Figure 7.7 (b)
If p = 13 we have:
1 2
3 5
1 3 4 9 10 12
= = = = = =1 4 6 2 5 6 7 8 11
13 13 13 13 13 13 = = = = = = –1
9 7 13 13 13 13 13 13
10 8
12 11
Quadratic Quadratic
residues non-residues
Figure 7.7 (c)
Proposition (7.8). Let p be an odd prime and a be an integer such that p a. Then
a p−1
( ) ≡ a 2 (mod p) .
p
Proof.
p−1
By Euler’s Criterion we have that a is a quadratic residue ⇔ a 2 ≡ 1 (mod p). By the above
definition of the Legendre symbol for integer a being a quadratic residue we have
a p−1
( ) = 1 ≡ 1 ≡ a 2 (mod p) .
p
p−1
a
Similarly, if a is a quadratic non-residue we have ( ) = −1 ≡ a 2 (mod p).
p
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
TH E L E G E N D R E SY M B O L ( 2 9 0 – 3 0 0 ) 293
We will see in the remainder of this section how the following properties of the Legendre
symbol can help us reduce the amount of work needed in determining whether a given
integer is a quadratic residue of an odd prime.
Proposition (7.9). Let p be an odd prime and a, b be integers such that p a and p b. We
have
a b
(a) If a ≡ b (mod p) then ( ) = ( ).
p p
a2
(b) ( ) = 1.
p
a×b a b
(c) ( ) = ( ) × ( ) (Multiplicative property).
p p p
Let us look at a numerical example for (a). We have 23 ≡ 2 (mod 7).
From Figure 7.7(a) we know 2 is a quadratic residue of 7, therefore 23 is also a quadratic
residue of 7 because x 2 ≡ 2 ≡ 23 (mod 7) has solutions. Hence the square root of 2 (mod 7)
and 23 (mod 7) both exist, so the Legendre symbol is (2/7) = (23/7) = 1.
Similarly 10 ≡ 3 (mod 7), but by Figure 7.7(a) we know that 3 is a quadratic non-residue
of 7, so 10 is also a quadratic non-residue of 7. Hence (3/7) = (10/7) = −1.
Proof of (a).
(a) We are given that a ≡ b (mod p), therefore x 2 ≡ a (mod p) has solutions
a b
⇔ x 2 ≡ b (mod p) because x 2 ≡ a ≡ b (mod p). Hence the Legendre symbols ( ) = ( ).
p p
[Either square roots of a (mod p) and b (mod p) both exist, or neither does.]
4
(b) A numerical example of (b) is ( ) = 1 because 22 ≡ 4 (mod 7). The square root of
7
4 (mod 7) is ±2 (mod 7).
Proof of (b).
a2
We are required to prove ( ) = 1. This means we need to prove x 2 ≡ a2 (mod p) has
p
solutions. By Proposition (3.14) (b):
a2 ≡ b2 (mod p) ⇔ a ≡ ±b (mod p) .
294 7 Q UA DRATIC R E S I D U E S
We can use this proposition to test whether a given integer is a quadratic residue of an
odd prime p.
Example 7.6
Test whether the following integers are quadratic residues of the corresponding prime:
(a) 177 of the prime 89 (b) 48 of the prime 79
Solution
(a) We have 177 ≡ 88 ≡ −1 (mod 89). We use the previous Proposition (7.9)(a):
177 −1
With a = 177, b = −1, and p = 89 we obtain ( ) = ( ).
89 89
We just need to test whether −1 is a quadratic residue of 89. Testing −1 gives
89−1 p−1
−1 a
( ) ≡ (−1) 2 [By (7.8) ( ) ≡ a 2 (mod p)]
89 p
44
≡ (−1) ≡ 1 (mod 89) .
−1
We have ( ) ≡ 1 (mod 89), so −1 is a quadratic residue of 89, which implies that 177 is also a
89
quadratic residue of 89. We can find the square root of 177 (mod 89).
(b) At the start of this section we posed the question of whether x 2 ≡ 48 (mod 79) is solvable or
not. Now we answer this question.
Integer 48 is a composite number because 16 × 3 = 42 × 3 = 48. This time we use the multiplicative
property (c) of the previous proposition:
a×b a b
( ) = ( ) × ( ).
p p p
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
TH E L E G E N D R E SY M B O L ( 2 9 0 – 3 0 0 ) 295
48 42 × 3 42 3 3 3
( )=( ) = ( )×( ) = ⏟1 ×( ) = ( ). (∗)
79 79 79 79 By (7.9)(b)
79 79
34 ≡ 81 ≡ 2 (mod 79) .
Hence, we use 34 ≡ 2 (mod 79) to find the least positive residue of 339 (mod 79):
9
339 ≡ 3(4×9)+3 ≡ (34 ) × 33 [By rules of indices]
≡ 29 × 27 [Because 34 ≡ 2 (mod 79)]
≡ 512 × 27 ≡ 38 × 27 ≡ 1026 ≡ 78 ≡ −1 (mod 79) .
48 3
( ) = ( ) = −1.
79 79
Since the Legendre symbol (48/79) = −1, so 48 is a quadratic non-residue of 79.
79−1
Notice how Proposition (7.9) makes life easier in evaluating 48 2 ≡ 4839 (mod 79).
296 7 Q UA DRATIC R E S I D U E S
1 3
2 5
4 6
3 × 5 ≡ 15 ≡ 1 (mod 7) ,
Clearly 1 is always a quadratic residue of an odd prime p. This means that the square root
of 1 (mod p) always exists.
1
Proposition (7.10). Let p be an odd prime. Then ( ) = 1.
p
Proof.
1
Since x 2 ≡ 1 ⇔ x ≡ ±1 (mod p), so ( ) = 1. This completes our proof.
p
Example 7.7
Solution
−1
(a) Note that in the previous Example 7.6 (a) we showed that ( ) ≡ 1 (mod 89), therefore −1
89
is a quadratic residue of 89.
−1
(b) We need to find the Legendre symbol ( ).
31
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
TH E L E G E N D R E SY M B O L ( 2 9 0 – 3 0 0 ) 297
How?
By using Euler’s Criterion (7.5):
p−1
a is a quadratic residue of p ⇔ a 2 ≡ 1 (mod p).
With p = 31 and a = −1 we have
p−1 31−1
15
a 2 ≡ (−1) 2 ≡ (−1) ≡ −1 (mod 31) .
Hence, we can find the square root of −1 (mod 89), but not of −1 (mod 31). This means
that −1 may or may not be a quadratic residue of a prime p.
−1 1 if p ≡ 1 (mod 4)
Proposition (7.11). Let p be an odd prime. Then ( )={ .
p −1 if p ≡ 3 (mod 4)
p−1
Note that for −1 to be a quadratic residue of an odd prime p then has to be even,
p−1
2
as then (−1) 2 will be 1.
This is what is captured by p ≡ 1 (mod 4) because this implies p − 1 = 4k so
p − 1 4k p−1
= = 2k. Therefore, is even.
2 2 2
Proof.
Use the above result of Exercises 7.1, question 7 with a = 1.
This means that −1 is a quadratic residue of a prime p of the form p ≡ 1 (mod 4) but not of
the prime p ≡ 3 (mod 4).
Example 7.8
298 7 Q UA DRATIC R E S I D U E S
Solution
In each case we use the result of the previous proposition.
(a) Since 1 000 000 000 061 ≡ 1 (mod 4), so the Legendre symbol is
−1
( ) = 1.
1 000 000 000 061
−1 is a quadratic residue of 1 000 000 000 061.
(b) Also 1 000 000 000 063 ≡ 3 (mod 4), therefore −1 is a quadratic non-residue of
1 000 000 000 063.
7.2.5 Factorization
−1 1 if p ≡ 1 (mod 4)
What does the above result ( )={ mean?
p −1 if p ≡ 3 (mod 4)
It means that the quadratic congruence x 2 ≡ −1 (mod p) has a solution if and only if the
odd prime p satisfies p ≡ 1 (mod 4). Using the definition of congruence we have
As stipulated at the start of this chapter, we can use this concept to factorize numbers of
the form x 2 + 1. Let us try some numerical values for x 2 + 1 and its factorization:
Note from the last column that all the odd prime factors p of x 2 + 1 satisfy p ≡ 1 (mod 4):
If there is a solution x such that x 2 + 1 ≡ 0 (mod p), which implies p | (x2 + 1), then
p ≡ 1 (mod 4).
This suggests that if we want to factorize an integer like x 2 + 1 then the odd prime factors
p of this x 2 + 1 will satisfy p ≡ 1 (mod 4). For example, if we want to factorize 262 + 1 = 677
then we know that all of the odd prime factors p of 262 + 1 = 677 satisfy p ≡ 1 (mod 4).
Actually 677 is prime and 677 ≡ 1 (mod 4).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
TH E L E G E N D R E SY M B O L ( 2 9 0 – 3 0 0 ) 299
Example 7.9
Solution
From above we have that the odd prime factors p of 462 + 1 = 2117 satisfy p ≡ 1 (mod 4). We trial the
first few primes of this format. Clearly 5 is not a factor of 2117. No point trying 7 or 11 because 7 ≢ 1
and 11 ≢ 1 (mod 4).
What about the next prime 13 because 13 ≡ 1 (mod 4)?
2117
= 162.846 …
13
Hence 13 is not a factor of 2117. Selecting the next few primes p which satisfy p ≡ 1 (mod 4) gives
17, 29, 37, 41, and we find that
2117
= 73.
29
73 is also prime and 73 ≡ 1 (mod 4), so 2117 = 29 × 73.
There are 14 primes below ⌊√462 + 1⌋ = 46, but we only need to test the six primes below
46 that are ≡ 1 (mod 4) to find a factor of 462 + 1 = 2117.
What we have seen is that if we are looking for the prime factors of an integer that looks
like x 2 + 1, we only need to try odd primes p that satisfy p ≡ 1 (mod 4).
Example 7.10
Solution
Well we have 63 ≡ −2 (mod 13). By the earlier Proposition (7.9):
−1 1 if p ≡ 1 (mod 4)
( )={
p −1 if p ≡ 3 (mod 4)
−1 −1 2
we have ( ) = 1. Substituting these results, ( ) = 1 and ( ) = −1, into (†) gives
13 13 13
63 −1 2
( ) = ( ) × ( ) = 1 × (−1) = −1.
13 13 13
So 63 is a quadratic non-residue of 13. [The square root of 63 (mod 13) does not exist.]
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
300 7 Q UA DRATIC R E S I D U E S
Summary
a 1 if a is a quadratic residue of p
The Legendre symbol is ( ) = {
p −1 if a is a quadratic non-residue of p
We use this and the properties of the Legendre symbol to determine whether a given integer is a
quadratic residue of an odd prime.
EXERCISES 7.2
(Brief solutions at end of book. Full not divide any of these integers. Prove
solutions available at <http://www.oup.co. that
uk/ companion/NumberTheory>.) a1 a a
( )×( 2)×⋯×( n) =
p p p
1. Show that the following integers are
a1 × a2 × ⋯ × an
quadratic residues of 31: ( )
p
(a) 35 (b) 71 (c) 56 a
where ( ) is the Legendre symbol.
p
(d) 94 (e) 47
6. Let a = p1 k1 × p2 k2 × ⋯ × pn kn be the
2. Determine whether the following
prime decomposition of a. Let p be
integers are quadratic residues
prime such that p a. Prove that
of 47:
k k kn
a p1 1 p 2 p
(a) 46 (b) 95 (c) 90 ( )=( ) ×( 2) ×⋯×( n)
p p p p
(d) 58 (e) 90 × 58 m
where ( ) is the Legendre symbol.
p
3. Factorize the following
p−1
integers: 7. Show that if p ≡ 1 (mod 4) then a 2
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 301
10. Prove that the Legendre symbol (b) Prove that r 2n+1 is a quadratic
non-residue of p.
ab2 a
( )=( ) *(c) By using the primitive root r show
p p p−1
that there are quadratic residues
2
given that gcd (a, p) = gcd (b, p) = 1. p−1
and quadratic non-residues of p.
2
11. Let p be an odd prime. Prove that
p−1 13. Determine the quadratic residues of
a a
∑ ( ) = 0 where ( ) is the Legendre the prime p = 17 by using the
a=1 p p
primitive root 3 modulo 17. Hence, or
symbol.
otherwise, find the square roots of
12. Let r be a primitive root of an odd 13 (mod 17).
prime p.
14. *Assuming 2 is a primitive root of the
(a) Prove that r 2n is a quadratic prime 101, find the square roots of
residue of p. 14 (mod 101).
.........................................................................................................
How do we test whether the quadratic congruence x 2 ≡ 713 (mod 4831) has solutions?
4831−1
713
We need to evaluate the Legendre symbol ( ) ≡ 713 2 ≡ 7132415 (mod 4831), which
4831
is still tedious even by using the properties of the Legendre symbol. We compute this Legen-
dre symbol in Example 7.18 towards the end of this section by applying the Law of Quadratic
Reciprocity (LQR) which is one of the most powerful results in number theory.
Rather than just formally state Gauss’s Lemma, we are going to explore some examples
to build up an intuitive understanding. Gauss’s Lemma helps determine whether a given
integer is a quadratic residue of an odd prime by counting negative residues. Example 7.11
demonstrates how.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
302 7 Q UA DRATIC R E S I D U E S
Example 7.11
Solution
It is not difficult to determine whether 7 is a quadratic residue of 11 because of the small numbers
involved. We can use Euler’s Criterion (7.5):
p−1
a is a quadratic residue of p ⇔ a 2 ≡ 1 (mod p).
Let a = 7 and p = 11, then we need to find the least positive residue x in
11−1
7 2 ≡ 75 ≡ x (mod 11) .
Normally the difficulty with Euler’s Criterion is evaluating 75 (mod 11). This is not too arduous be-
cause 5 is not a large index. However, we are going to tackle this problem differently because in general
there is no easy way to find x.
11 − 1
Let a = 7 and b be the first = 5 least positive integers 1, 2, 3, 4, and 5. Multiplying each of
2
these b’s by 7 we have:
b 1 2 3 4 5
7 × b (mod 11) 7 14 ≡ 3 21 ≡ 10 28 ≡ 6 35 ≡ 2
p − 1 11 − 1
Those products whose least positive residue is greater than = = 5 we can write as a
2 2
negative residue, giving us:
7 × b (mod 11) 7 ≡ −4 3 10 ≡ −1 6 ≡ −5 2
3
We have 75 ≡ (−1) ≡ −1 (mod 11). Now by Euler’s Criterion we conclude that 7 is a quadratic non-
residue of 11.
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 303
In the previous Example 7.11 we wrote any residues of the product greater than (p − 1) /2
as negative residues.
0(mod p)
–1(mod p) 1(mod p)
–2(mod p) 2(mod p)
Modulo p
Negative Positive
–3(mod p) 3(mod p)
(p-1)/2(mod p)
Figure 7.9
In the previous Example 7.11 we used Euler’s Criterion which meant we needed to find
11−1
1
7 2 (mod 11). That is why we found the first half, 1 to (11 − 1) = 5 multiples of 7 rather
2
than the whole lot from 1 to 10. We considered only the first half of the least positive
residues. So, in order to determine the number of negative residues of the product, we
p−1
write any residue greater than halfway as a negative residue.
2
Another example will help clarify the idea.
Example 7.12
Solution
17 − 1
We start with the first half of the residues from 1 to = 8, that is 1, 2, 3, 4, 5, 6, 7, and 8. We can
2
create a table of values:
b 1 2 3 4 5 6 7 8
2 × b (mod 17) 2 4 6 8 10 ≡ −7 12 ≡ −5 14 ≡ −3 16 ≡ −1
Notice that any residue of the product greater than 8 has been written as a negative residue. Multiply-
ing these, we have
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
304 7 Q UA DRATIC R E S I D U E S
(2 × 1) × (2 × 2) × (2 × 3) × (2 × 4) × (2 × 5) × (2 × 6) × (2 × 7) × (2 × 8) ≡ 2 × 4 × 6 × 8 × (−7)
× (−5) × (−3) × (−1)
4
28 (1 × 2 × 3 × 4 × 5 × 6 × 7 × 8) ≡ (−1) (1 × 2 × 3 × 4 × 5 × 6 × 7 × 8)
4
28 8! ≡ (−1) 8!
4
28 ≡ (−1) (mod 17) .
4
We have 28 ≡ (−1) ≡ 1 (mod 17), so by Euler’s Criterion we conclude that 2 is a quadratic residue
of 17.
g
In both examples we ended up with (−1) where g is the number of negative residues in
the product. This is no coincidence. Note, though, that we can reason that when g is even
our integer a will be a quadratic residue, but when it is odd it will be a quadratic non-residue.
In order to prove Gauss’s Lemma we need a couple of lemmas:
Lemma (7.12). Let p be an odd prime and a be an integer such that p a. The following
residues:
p−1
a, 2a, 3a, ⋯ , ( ) a (mod p) are incongruent.
2
Proof.
Suppose two of the residues in the given list are congruent to each other:
p−1
ka ≡ ma (mod p) where k, m ∈ {1, 2, 3, ⋯ , }.
2
Required to prove that k = m, because this will imply ka and ma are the same residue.
We have (k − m) a ≡ 0 (mod p). Applying Proposition (3.14) (a):
Lemma (7.13). Let p be an odd prime and a be an integer such that p a. Then
p−1
a, 2a, 3a, ⋯ , ( ) a ≢ 0 (mod p) .
2
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 305
Proof.
See Exercises 7.3, question 4.
Gauss’s Lemma (7.14). Let p be an odd prime and a be an integer such that p a. Consider
the set of the product of a and the first half of least positive residues of p:
p−1
S = {a, 2a, 3a, ⋯ , ( ) a} .
2
Let g be the number of negative residues in this list; these are the ones which are greater
p−1 a g
than . Then the Legendre symbol is given by ( ) = (−1) .
2 p
Proof.
Consider the p − 1 least positive residues modulo p:
1, 2, 3, ⋯ , −3 ,
p⏟ −2 ,
p⏟ −1 .
p⏟
≡−3(mod p) ≡−2(mod p) ≡−1(mod p)
p+1
We can write the integer in (∗) as a negative residue because
2
p+1 p−1 p−1
≡ p− ≡− (mod p) .
2 2 2
Writing the last half of the list in (∗) as negative residues gives
p−1 p−1
1, 2, 3, ⋯ , , − , ⋯ , −3, −2, −1 . (∗∗)
⏟⎵⎵⎵⎵⏟⎵⎵⎵⎵⏟ 2 ⏟⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⏟
2
First (p−1)/2 residues Last (p−1)/2 residues
306 7 Q UA DRATIC R E S I D U E S
0(mod p)
–1(mod p) 1(mod p)
–3(mod p) 3(mod p)
–((p–1)/2)(mod p) (p–1)/2(mod p)
Figure 7.10
Why?
Because this list (∗∗) covers all the non-zero residues modulo p. If ka is an integer in set S
then it can be expressed as an integer in (∗∗), which we can write as an element in
p−1 p−1
{− , ⋯ , −3, −2, −1, 1, 2, 3, ⋯ , }.
2 2
p−1 p−1
Multiplying these residues of S = {a, 2a, 3a, ⋯ , ( ) a} gives
2 2
p−1 g p−1
(a × 1) × (a × 2) × (a × 3) × ⋯ × (a × ) ≡ (−1) (1 × 2 × 3 × ⋯ × )
2 2
g is the number of
[ ]
negative residues in S
p−1 p−1 g p−1
a 2 ( )! ≡ (−1) ( )!
2 2
p−1
g
a 2 ≡ (−1) (mod p) . (†)
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 307
Example 7.13
2
Determine ( ) using Gauss’s Lemma.
19
Solution
Gauss’s Lemma (7.14):
g
(a/p) = (−1) where g is the number of negative residues.
We need to examine the product of 2 and the first half of the least positive residues modulo 19:
19 − 1
S = {2 (1) , 2 (2) , 2 (3) , ⋯ , 2 ( )} = {2, 4, 6, 8, 10, 12, 14, 16, 18} (mod 19).
2
p − 1 19 − 1
We divide this set S into two equal halves by writing the residues greater than = = 9 as
2 2
negative residues.
Hence, we write the above set S as
S = {2, 4, 6, 8, 10, 12, 14, 16, 18} = {2, 4, 6, 8, −9, −7, −5, −3, −1} (mod 19) .
2 5
There are five negative residues in S, so by Gauss’s Lemma ( ) = (−1) = −1.
19
The Legendre symbol is equal to −1, therefore 2 is a quadratic non-residue modulo 19.
p−1 19 − 1
In the above set S there are = = 9 residues and five of these are negative
2 2
and four are positive. To use Gauss’s Lemma, we don’t need to worry about the number of
positive residues, our concern is only with the number of negative residues in this list.
Example 7.14
2
Determine ( ) using Gauss’s Lemma.
41
Solution
We split the product of 2 and the least positive residues into two equal halves, where the split occurs
p − 1 41 − 1
halfway at = = 20. We have the following for the prime 41:
2 2
2 10
Since we have ten negative residues, so by Gauss’s Lemma we have ( ) = (−1) = 1.
41
Therefore, 2 is a quadratic residue of 41, so the square root of 2 modulo 41 exists.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
308 7 Q UA DRATIC R E S I D U E S
In this subsection we test for which prime moduli the integer 2 is a quadratic residue, that
is we need to find for which primes we can find the square root of 2 modulo p.
2 1 if p ≡ ±1 (mod 8)
Proposition (7.15). Let p be an odd prime. Then ( ) = { .
p −1 if p ≡ ±3 (mod 8)
This implies that any odd prime factor p of the integer x 2 − 2 satisfies p ≡ ±1 (mod 8).
We can use this to factorize integers which look like x 2 − 2. Let us try some numerical
values for x 2 − 2 and its factorization:
Note from the last column that all the odd prime factors p of x 2 − 2 satisfy
p ≡ ±1 (mod 8):
This suggests that if we wanted to factorize an integer like x 2 − 2 then the odd prime factor p
of this will satisfy p ≡ ±1 (mod 8). For example, if we want to factorize 652 − 2 = 4223 then
we know all the prime factors p of 652 − 2 = 4223 satisfy p ≡ ±1 (mod 8). In the example
below, we factorize this number.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 309
Example 7.15
Solution
By the above theory, the prime factors p of 4223 satisfy p ≡ ±1 (mod 8). The first few primes of this
form are 7, 17, 23, 31, 41, 47. We don’t need to find any other primes because ⌊√4223⌋ = 64, and
these are the only primes below 64 which satisfy p ≡ ±1 (mod 8). There are 18 primes below 64, but
we only need to check these six.
4223
The prime 41 goes into 4223 because = 103, which implies 4223 = 41 × 103. Both primes 41
41
and 103 are congruent to 1 and −1 modulo 8 respectively.
Apply Gauss’s Lemma (7.14) and consider the four odd primes p such that
p ≡ ±1, ±3 (mod 8) .
Proof of (7.15).
Consider the set of the product of 2 and the first half of least positive residues of p:
p−1
S = {2 (1) , 2 (2) , 2 (3) , ⋯ , 2 ( )} (mod p) .
2
p−1
The number of negative residues g are the ones greater than . This is given by:
2
g = (number of residues in S) − (number of positive residues in S)
p−1 p
= − (number of residues r which satisfy 2r < )
2 2
p−1 p p−1 p
= − (number of residues r < ) = − ⌊ ⌋ (where ⌊ ⌋ is the floor function) .
2 4 2 4
p−1 p
Therefore, g = − ⌊ ⌋ gives the number of negative residues in the set S. Then by
2 4
Gauss’s Lemma we have
2 g
( ) = (−1) .
p
Case I
If p ≡ 1 (mod 8) then p is one more than a multiple of 8; p = 8k + 1 where k is a positive
integer, and so substituting this into the above g gives
p−1 p 8k + 1 − 1 ⎢ 8k + 1 ⎥ 8k 1
g= −⌊ ⌋ = − = − ⌊2k + ⌋ = 4k − 2k = 2k.
2 4 2 ⎣ 4 ⎦ 2 4
Case II
If p ≡ −1 (mod 8) then p = 8k − 1, and so
p−1 p 8k − 1 − 1 ⎢ 8k − 1 ⎥ 8k 2 1
g= −⌊ ⌋ = − = − − ⌊2k − ⌋ = 4k − 1 − (2k − 1) = 2k.
2 4 2 ⎣ 4 ⎦ 2 2 4
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
310 7 Q UA DRATIC R E S I D U E S
Combining both these cases (I and II) we have that when p ≡ ±1 (mod 8) then
2 g
g = 2k, which is even, so ( ) = (−1) = (−1) = 1. Hence 2 is a quadratic residue if
2k
p
p ≡ ±1 (mod 8).
Case III
If p ≡ 3 (mod 8) then p = 8k + 3 and
p−1 p 8k + 3 − 1 ⎢ 8k + 3 ⎥ 8k 2 3
g= −⌊ ⌋ = − = + − ⌊2k + ⌋ = 4k + 1 − (2k) = 2k + 1.
2 4 2 ⎣ 4 ⎦ 2 2 4
Case IV
If p ≡ −3 (mod 8) then we can write this as p = 8k − 3 and
p−1 p 8k − 3 − 1 ⎢ 8k − 3 ⎥ 8k 4 3
g= −⌊ ⌋ = − = − − ⌊2k − ⌋ = 4k − 2 − (2k − 1)
2 4 2 ⎣ 4 ⎦ 2 2 4
= 2k − 1.
Again, combining the last two cases (III and IV) together, we have:
2 g
When p ≡ ±3 (mod 8) then g = 2k ± 1 which is odd, so ( ) = (−1) = (−1)
2k±1
= −1.
p
Therefore, 2 is a quadratic non-residue if p ≡ ±3 (mod 8). This completes our proof.
Next, we state one of the most important and powerful results in number theory. The proof
of this is given in the next section.
Law of Quadratic Reciprocity (LQR) (7.16). Let p and q be distinct odd primes. Then
p q (
p−1
)×(
q−1
)
( ) × ( ) = (−1) 2 2 .
q p
Proof.
See next section.
Proof.
See next section.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 311
We use this corollary to test if a given integer is a quadratic residue of an odd prime p.
For example, the following Legendre symbols are equivalent:
5 31
( ) = ( ) because 5 ≡ 1 (mod 4) .
31 5
7 31
( ) = − ( ) because 7 ≡ 31 ≡ 3 (mod 4) .
31 7
This corollary is normally used in conjunction with the properties of the Legendre symbol
established in Proposition (7.9):
a b a2 a×b a b
(a) If a ≡ b (mod p) then ( ) = ( ) (b) ( ) = 1 (c) ( ) = ( )×( )
p p p p p p
Example 7.16
101
Evaluate the Legendre symbol ( ) where 61 is prime.
61
Solution
If we used Euler’s Criterion, then we would need to find
61−1
101 2 ≡ 10130 (mod 61) .
To determine whether 10130 ≡ ±1 (mod 61) is a laborious task. Much easier to use the previous
Corollary (7.17) and the properties of the Legendre symbol.
101 40 23 × 5 22 × 2 × 5 22 2 5 2 5
( )=( )=( )=( )= ( ) ×( ) × ( ) = ( ) × ( ). (†)
61 61 61 61 ⏟61 61 61 61 61
=1 because 22 is QR
2
To compute ( ) we use Proposition (7.15):
61
2 1 if p ≡ ±1 (mod 8)
( )={
p −1 if p ≡ ±3 (mod 8)
2
Since p = 61 ≡ 5 ≡ −3 (mod 8), so ( ) = −1.
61
5
Evaluating the other Legendre symbol in (†), ( ), we have (by using the previous formula (7.17)):
61
2 5
Substituting ( ) = −1 and ( ) = 1 into (†) gives
61 61
101 2 5
( ) = ( ) × ( ) = (−1) × 1 = −1.
61 61 61
101
Hence ( ) = −1 implies that 101 is a quadratic non-residue of 61. The square root of 101 modulo
61
61 does not exist.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
312 7 Q UA DRATIC R E S I D U E S
Example 7.17
Solution
15
We need to show that the Legendre symbol ( ) = 1. Since 15 = 3 × 5, so
173
3×5 3 5
( )=( )×( ). (∗)
173 173 173
2 1 if p ≡ ±1 (mod 8)
( )={
p −1 if p ≡ ±3 (mod 8)
2 5 2
Since 3 ≡ 3 (mod 8), so ( ) = −1, which implies ( ) = ( ) = −1.
3 173 3
3
We also need to evaluate ( ) in (∗):
173
5 3
Putting these evaluations, ( ) = −1 and ( ) = −1, into (∗) gives
173 173
15 5 3
( )=( )×( ) = (−1) × (−1) = 1.
173 173 173
Hence 15 is a quadratic residue of 173. [Note that 5 and 3 are quadratic non-residues of 173.]
Now we test whether we can find solutions to x 2 ≡ 713 (mod 4831) which we stated at
the start of this section.
Example 7.18
713
Evaluate the Legendre symbol ( ) where 4831 is prime. [Hint: 713 = 23 × 31.]
4831
Solution
By the given hint and multiplicative property of the Legendre symbol, we have
713 23 × 31 23 31
( )=( )=( )×( ). (∗)
4831 4831 4831 4831
Computing each of the Legendre symbols on the right-hand side separately.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Q UA D R AT I C R E C I P R O C I T Y ( 3 0 1 – 3 1 4 ) 313
23
Evaluating ( ):
4831
p q
23 4831 Using (7.17); ( ) = − ( ) if p ≡ q ≡ 3 (mod 4)
( ) = −( ) [ q p ]
4831 23 because 23 ≡ 4831 ≡ 3 (mod 4)
1
= −( ) [Because 4831 ≡ 1 (mod 23)]
23
= −1 [Because 1 is always a quadratic residue] .
31
Evaluating the other Legendre symbol ( ):
4831
2 1 if p ≡ ±1 (mod 8)
( )={
p −1 if p ≡ ±3 (mod 8)
2
we have ( ) = 1. Evaluating the other Legendre symbol on the right-hand side of (†):
31
2 13 2
Substituting our calculations ( ) = 1 and ( ) = ( ) = −1 into (†) yields
31 31 3
31 2 13
( ) = − ( ) × ( ) = − (1) × (−1) = 1.
4831 31 31
31 23
Putting our computations, ( ) = 1 and ( ) = −1, into (∗) gives
4831 4831
713 23 31
( )=( )×( ) = (−1) × 1 = −1. (‡)
4831 4831 4831
713
Since ( ) = −1, so 713 is a quadratic non-residue of the odd prime 4831. This means that the
4831
quadratic congruence x 2 ≡ 713 (mod 4831) has no solutions.
Note that by (‡) we have that 23 is a NR and 31 is a QR of the prime 4831.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
314 7 Q UA DRATIC R E S I D U E S
We can also use the Law of Quadratic Reciprocity to find a primitive root of a modulo
prime and find the square root of a (mod p) (see Exercises 7.3, question 15).
By using the Law of Quadratic Reciprocity, we normally end up testing either −1 or 2
for quadratic residue. It is worth investing some time learning for which primes these two
integers (−1 and 2) are quadratic residues. We repeat the odd primes p for which these are
quadratic residues or quadratic non-residues:
−1 1 if p ≡ 1 (mod 4)
(7.11) ( )={
p −1 if p ≡ 3 (mod 4)
2 1 if p ≡ ±1 (mod 8)
(7.15) ( )={
p −1 if p ≡ ±3 (mod 8)
p2 −1
2
Corollary (7.18). Let p be an odd prime then ( ) = (−1) 8 .
p
Proof.
See Exercises 7.3, question 5.
Summary
We can simplify the evaluation of the Legendre symbol by using the Law of Quadratic Reciprocity
(LQR) and its corollary.
We used Gauss’s Lemma to establish for which primes 2 is a quadratic residue.
EXERCISES 7.3
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 315
.........................................................................................................
316 7 Q UA DRATIC R E S I D U E S
Law of Quadratic Reciprocity (LQR) (7.16). Let p and q be distinct odd primes. Then
p q (
p−1
)×(
q−1
)
( ) × ( ) = (−1) 2 2 .
q p
Well in the last couple of sections we established a rule for testing the integers −1 and 2 by
looking at a given prime and seeing how it was related to modulo 4 and 8 respectively.
10
Say we wanted to find the Legendre symbol ( ) where the prime, p say, is >100. We know
p
10 = 2 × 5, so we have
10 2 5
) = ( ) × ( ).
(
p p p
For evaluating (2/p) we can use (7.15) from the last section:
2 1 if p ≡ ±1 (mod 8)
( )={
p −1 if p ≡ ±3 (mod 8)
If 5 and p are distinct odd primes then we can use LQR (7.16) or Corollary (7.17).
In general, if we want to test whether integer a is a quadratic residue of an odd prime p
then we decompose a into its prime decomposition and then apply Corollary (7.17).
For example, if a = q1 × q2 × ⋯ × qm where q’s are primes then the Legendre symbol
a q1 × q2 × ⋯ × qm q1 q2 qm
( )=( ) = ( ) × ( ) × ⋯ × ( ).
p p p p p
This means that we can use the Law of Quadratic Reciprocity or its corollary to find the
Legendre symbol (a/p) which tells us whether a is a quadratic residue modulo p.
In this section we prove LQR (7.16), but before we can do this we need to establish some
results. Consider the following example.
Example 7.19
p−1 q−1
( )×( )
Determine (−1) 2 2 for:
(a) p ≡ q ≡ 1 (mod 4) (b) p ≡ q ≡ 3 (mod 4)
(c) p ≡ 1 (mod 4), q ≡ 3 (mod 4) (d) p ≡ 3 (mod 4), q ≡ 1 (mod 4)
Solution
(a) We are given p ≡ q ≡ 1 (mod 4), so there are positive integers k and m such that
p = 4k + 1 and q = 4m + 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 317
p−1 q−1
Substituting these p = 4k + 1 and q = 4m + 1 into the index ( )×( ) gives
2 2
p−1 q−1 4k + 1 − 1 4m + 1 − 1
( )×( )=( )×( ) = 2k × 2m [Even integer].
2 2 2 2
p−1 q−1
( )×( ) 2k×2m
Hence (−1) 2 2 = (−1) = 1, because we have an even index.
(b) Similarly, for p ≡ q ≡ 3 (mod 4) we have positive integers k and m such that
p = 4k + 3 and q = 4m + 3.
p−1 q−1
Substituting these p = 4k + 3 and q = 4m + 3 into the index ( )×( ) gives
2 2
p−1 q−1 4k + 3 − 1 4m + 3 − 1
( )×( )=( )×( )
2 2 2 2
= (2k + 1) × (2m + 1) = 4km + 2k + 2m + 1 [Odd integer] .
p−1 q−1
( )×( ) 4km+2k+2m+1
Hence (−1) 2 2 = (−1) = −1 because we have an odd index.
p−1 q−1
p q ( )×( )
From these results of Example 7.19, what can we conclude about ( ) × ( ) = (−1) 2 2 ?
q p
Apart from when both p ≡ q ≡ 3 (mod 4), we have
p q (
p−1
)×(
q−1
)
( ) × ( ) = (−1) 2 2 = 1.
q p
p q p q
( ) = 1 and ( ) = −1 or ( ) = −1 and ( ) = 1.
q p q p
The Legendre symbols in this case are different, that is p is a quadratic residue of q but q is
a quadratic non-residue of p or vice versa.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
318 7 Q UA DRATIC R E S I D U E S
The proof of the Law of Quadratic Reciprocity given towards the end of this section is the
one given by Gotthold Eisenstein.
Eisenstein met Gauss at the University of Göttingen in 1844 and Gauss was impressed by
Eisenstein’s proof of the Law of Quadratic Reciprocity.
Before we state Eisenstein’s Lemma, which is going to help us to prove the Law of
Quadratic Reciprocity, we demonstrate a numerical example of the lemma.
Example 7.20
(q−1)/2 (p−1)/2
p×k⎥ q×k⎥
Determine ∑ ⎢ + ∑ ⎢ where ⌊ ⌋ is the floor function, p = 11, and q = 13. Also
k=1 ⎣ q ⎦ k=1⎣ p ⎦
p−1 q−1
evaluate ( )×( ).
2 2
What do you notice about your results?
Solution
Evaluating the first expression on the left-hand side by substituting p = 11 and q = 13 gives
(q−1)/2 (13−1)/2
p×k⎥
∑ ⎢ = ∑ ⎢ 11 × k ⎥
k=1 ⎣
q ⎦ k=1 ⎣ 13 ⎦
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 319
6
11 × k ⎥ 11 × 1 11 × 2 11 × 3 11 × 4 11 × 5 11 × 6
= ∑⎢ =⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋
k=1 ⎣
13 ⎦ 13 13 13 13 13 13
11 22 33 44 55 66
=⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋
13 13 13 13 13 13
= 0 + 1 + 2 + 3 + 4 + 5 = 15 [Remember ⌊ ⌋ is the floor function] .
(p−1)/2 (11−1)/2 5
q×k⎥
∑ ⎢ = ∑ ⎢ 13 × k ⎥ = ∑ ⎢ 13 × k ⎥
k=1 ⎣
p ⎦ k=1 ⎣ 11 ⎦ k=1 ⎣ 11 ⎦
13 × 1 13 × 2 13 × 3 13 × 4 13 × 5
=⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋
11 11 11 11 11
13 26 39 52 65
= ⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋
11 11 11 11 11
= 1 + 2 + 3 + 4 + 5 = 15
(q−1)/2 (p−1)/2
p×k⎥ q×k⎥
∑ ⎢ + ∑ ⎢ = 15 + 15 = 30.
k=1 ⎣
q ⎦ k=1 ⎣
p ⎦
p−1 q−1
Working out ( )×( ) with p = 11 and q = 13 yields
2 2
11 − 1 13 − 1
( )×( ) = 5 × 6 = 30.
2 2
(q−1)/2 (p−1)/2
p×k⎥ q×k⎥ p−1 q−1
In this case we have ∑ ⎢ + ∑ ⎢ =( )×( ).
k=1 ⎣ q ⎦ k=1 ⎣ p ⎦ 2 2
q p
We can illustrate this example graphically by drawing a line y = x or x = y and counting
p q
the number of integer (lattice) points above and below this line:
Figure 7.12
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
320 7 Q UA DRATIC R E S I D U E S
By lattice point, we mean a point whose (x and y) coordinates are both integers.
13
We can count the number of lattice points below the line y = x by counting each of the
11
13
lattice points on the vertical lines x = 1, 2, 3, 4 and 5 but below the diagonal y = x, as
11
shown in Figure 7.12. This is the sum evaluated in the previous Example 7.20:
5
13 × k ⎥
∑⎢ = 1 + 2 + 3 + 4 + 5 = 15.
k=1 ⎣ 11 ⎦
11
Similarly, the number of lattice points above the diagonal x = y is counted by the num-
13
ber of lattice points on horizontal lines y = 1, 2, 3, 4, 5 and 6.
This is given by the calculation in Example 7.20:
6
11 × k ⎥
0+1+2+3+4+5 = ∑⎢ = 15.
k=1 ⎣ 13 ⎦
As you can see from Figure 7.12, the number of lattice points inside the rectangle between
0 and p/2 = 11/2 and 0 and q/2 = 13/2 is
p−1 q−1 11 − 1 13 − 1
( )×( )=( )×( ) = 5 × 6 = 30.
2 2 2 2
13
Since p = 11 and q = 13 are distinct odd primes, the straight line y = x does not lie on
11
any of the lattice points between x = 0 and p/2 = 11/2 and y = 0 and q/2 = 13/2.
(q−1)/2 (p−1)/2
p × k⎥ q × k⎥ p−1 q−1
This result from the above example ∑ ⎢ + ∑ ⎢ =( )×( )
k=1 ⎣ q ⎦ k=1 ⎣ p ⎦ 2 2
is not just true for these distinct primes, but is true for all distinct odd primes p and q.
This is Eisenstein’s Lemma.
We have demonstrated a numerical example, but now we prove this general result.
Proof.
p×k q−1
We are given that p and q are distinct, so for any k from 1 to cannot be an integer.
q 2
q×k p−1
Similarly, for any k from 1 to cannot be an integer.
p 2
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 321
q × k⎥
Recall ⎢ is the floor function which counts the number of positive integers
⎣ p ⎦
q×k
≤ .
p
We need to find the number of lattice points (positive integers) below the line
q q×x
y= x= , that is in the lower triangle ACD shown in Figure 7.13:
p p
p−1
Figure 7.13 x =
2
The floor function ⌊(q × k) /p⌋ gives the number of lattice points on the vertical line x = k
which lies in the lower triangle ACD.
q × k⎥
The number of lattice points on each vertical line x = k is ⎢ . We sum the number of
⎣ p ⎦
(p−1)/2
p−1 q × k⎥
lattice points on each of the lines from x = 1 to x = which is given by ∑ ⎢ ,
2 k=1 ⎣ p ⎦
which is the total number of lattice points in the lower triangle ACD.
Similarly, we count the lattice points in the upper triangle ABC as shown in Figure 7.14
on the next page.
p × k⎥
The floor function ⎢ gives the number of lattice points on the horizontal line y = k
⎣ q ⎦
which lie in the triangle ABC, as shown below.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
322 7 Q UA DRATIC R E S I D U E S
Figure 7.14
We want to find the total number of lattice points in this triangle ABC.
How?
We find the number of lattice points along each of the horizontal lines from y = 1 to
q−1 p × k⎥
y= . Each horizontal line y = k has ⎢ lattice points in the triangle ABC and
2 ⎣ q ⎦
q−1 p × k⎥ q−1
we have y = 1, ⋯ , y = horizontal lines, so we sum ⎢ from k = 1 to k = :
2 ⎣ q ⎦ 2
(q−1)/2
p × k⎥
∑ ⎢ .
k=1 ⎣
q ⎦
(q−1)/2
p × k⎥
This sum ∑ ⎢ gives us the total number of lattice points in the upper triangle
k=1 ⎣ q ⎦
ABC shown in Figure 7.15 below:
Figure 7.15
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 323
The total number of lattice points in the rectangle ABCD is given by adding the lattice
points in each triangle, that is
(q−1)/2 (p−1)/2
p × k⎥ q × k⎥
∑ ⎢ + ∑ ⎢ .
k=1 ⎣
q ⎦ k=1 ⎣
p ⎦
⏟⎵⎵⎵⏟⎵⎵⎵⏟ ⏟⎵⎵⎵⏟⎵⎵⎵⏟
=Number of lattice points in triangle ABC =Number of lattice points in triangle ACD
Clearly the number of lattice points inside the rectangle ABCD shown in the above diagram
p−1 q−1
is ( )×( ). Hence we have our result:
2 2
(q−1)/2 (p−1)/2
p × k⎥ q × k⎥ p−1 q−1
∑ ⎢ + ∑ ⎢ =( )×( ).
k=1 ⎣
q ⎦ k=1 ⎣
p ⎦ 2 2
We use this lemma to prove the Law of Quadratic Reciprocity. Before we provide the
proof we look at a numerical example, as well as stating the remaining lemma.
Example 7.21
(p−1)/2
a×k⎥
∑ ⎢ ≡ g (mod 2)
k=1 ⎣ p ⎦
Solution
p − 1 23 − 1
We are given that p = 23, a = 3 and k = 1, 2, 3, ⋯ , = = 11.
2 2
(p−1)/2
⎢ a × k ⎥ 11 3k
Evaluating the summation ∑ = ∑ ⌊ ⌋ gives
k=1 ⎣ p ⎦ k=1 23
11
3k 3 6 9 12 15 18 21 24 27 30 33
∑ ⎢ ⎥ = ⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋+⌊ ⌋
k=1 ⎣ 23 ⎦ 23 23 23 23 23 23 23 23 23 23 23
= 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 = 4.
Writing the elements a × k (mod 23) in the set S and any least residue > 11 as a negative residue,
we have
S = {3, 3 (2) , 3 (3) , 3 (4) , 3 (5) , 3 (6) , 3 (7) , 3 (8) , 3 (9) , 3 (10) , 3 (11) } (mod 23)
≡ {3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33} ≡ {3, 6, 9, − 11, −8, −5, −2 , 1, 4, 7, 10} (mod 23) .
⏟⎵⎵⎵⎵⏟⎵⎵⎵⎵⏟
There are 4 negative residues
Since there are four negative residues modulo 23 in the above set S, so g = 4. We have
11
3k
∑ ⎢ ⎥ = 4 ≡ g (mod 2) .
k=1 ⎣ 23 ⎦
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
324 7 Q UA DRATIC R E S I D U E S
Lemma (7.20). Let p be an odd prime and a also be odd such that p a. Let g be the number
of negative residues as defined in Gauss’s Lemma (7.14). We have
(p−1)/2
a × k⎥
∑ ⎢ ≡ g (mod 2) .
k=1 ⎣ p ⎦
Proof.
See Exercises 7.4, question 10.
Note: Lemma (7.20) can be understood as follows: g (mod 2) is either 1 (in the case that
g is odd) or 0 (in the case that g is even). From Gauss’s Lemma we know that the Legendre
a
symbol ( ) is equal to (−1)g where g is the number of negative residues. Well, the actual
p
value of g is not too important, but what is important is whether g is odd or even.
Law of Quadratic Reciprocity (LQR) (7.16). Let p and q be distinct odd primes. Then
p q (
p−1
)×(
q−1
)
( ) × ( ) = (−1) 2 2 .
q p
Proof.
p−1
Consider the least positive residues modulo p which are the product of q and the first
2
least positive residues:
p−1
S = {q, 2q, 3q, ⋯ , ( ) q} (mod p) .
2
By the previous Lemma (7.20) with a = q we have
(p−1)/2
k × q⎥
∑ ⎢ ≡ g (mod 2) (†)
k=1 ⎣
p ⎦
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 325
(q−1)/2 (p−1)/2
k × p⎥ k × q⎥ p−1 q−1
∑ ⎢ + ∑ ⎢ =( )×( ).
k=1 ⎣
q ⎦ k=1 ⎣
p ⎦ 2 2
Substituting this into the last line of the above calculation yields
(p−1)/2 (q−1)/2
k×q k×p
p q ∑ ⌊
p
⌋+ ∑ ⌊
q
⌋ (
p−1
)×(
q−1
)
( ) × ( ) = (−1) k=1 k=1 = (−1) 2 2 .
q p
This is our required result.
This Law of Quadratic Reciprocity (LQR) is a very powerful result, as you may have
noticed from the last section. A more useful result, which was stated in the last section, is:
Proof.
See Exercises 7.4, question 9.
We have used this corollary to see if a given integer is a quadratic residue of an odd prime
p in the last section. We apply this again in the example below.
Example 7.22
Solution
35
We need to evaluate the Legendre symbol ( ). Since 35 = 5 × 7, so we have
541
35 5 7
( )=( )×( ). (∗)
541 541 541 (continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
326 7 Q UA DRATIC R E S I D U E S
All of 5, 7, and 541 are distinct odd primes, so we can use the previous Corollary (7.17):
Since 5 ≡ 1 (mod 4), so using this on the first term on the right-hand side of (∗) gives
5 541 1
( )=( )=( )=1 [Because 541 ≡ 1 (mod 5)] .
541 5 5
Examining the second term on the right-hand side of (∗) we have 7 ≡ 3 (mod 4) but
541 ≡ 1 (mod 4), so using the above corollary we have
7 541 2
( )=( )=( ) [Because 541 ≡ 2 (mod 7)] .
541 7 7
We have already established a test for the residue 2, Proposition (7.15):
2 1 if p ≡ ±1 (mod 8)
( )={
p −1 if p ≡ ±3 (mod 8)
2
Since 7 ≡ −1 (mod 8), so applying this we have ( ) = 1.
7
5 2
Multiplying these two Legendre symbols ( ) = 1 and ( ) = 1 of (∗) together gives
541 7
35 5 7
( )=( )×( ) = 1 × 1 = 1.
541 541 541
Hence x 2 ≡ 35 (mod 541) is solvable. (We can find the square root of 35 modulo 541.)
Summary
p−1 q−1
p q ( )×( )
In this section we have proven the Law of Quadratic Reciprocity (LQR), ( ) × ( ) = (−1) 2 2 ,
q p
by using Eisenstein’s Lemma.
EXERCISES 7.4
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 327
3. Show that if p and q are distinct odd 11. Let p = 13 and a = 16. Show that
primes then (p−1)/2
ka
1 if p ≡ 1 (mod 4) or ∑ ⎢ ⎥ = 23 but g = 2 where g is
p q k=1 ⎣ p⎦
( )×( ) = { q ≡ 1 (mod 4)
q p as defined in Gauss’s Lemma. Explain
−1 if p ≡ q ≡ 3 (mod 4)
why Lemma (7.20) fails in this case.
4. Prove that for prime p > 3 we have 12. Prove that the odd prime divisors
p
( ) if p ≡ 1 (mod 4) of the integer n2 + 1 are of the form
3
( ) = { p3 4k + 1.
p −( ) if p ≡ 3 (mod 4)
3 13. Prove that there are infinitely many
5. (i) Prove that for prime p > 3 we have primes of the form 3m + 1 without
1 if p ≡ 1 (mod 6) using Dirichlet’s Theorem. [Hint: You
−3
( )={ may find the result of question 5
p −1 if p ≡ 5 (mod 6) helpful.]
(ii) Determine the prime factorization 14. Determine the least positive residues x
of the following: in the following cases (1993 is prime):
(a) 1042 + 3 = 10 819
(a) 25997 ≡ x (mod 1993)
(b) 2362 + 3 = 55 699 (b) 26997 ≡ x (mod 1993)
(c) 3622 + 3 = 131 047
15. Prove that if the prime p = 8k + 1 then
6. Show that the prime factors p > 3 of p−1
328 7 Q UA DRATIC R E S I D U E S
19. *Prove the following for prime p where 21. Prove that there are infinitely many
p 7: primes of the form 3n − 1.
7
( ) = 1 if p ≡ ±1, ±3, ±9 (mod 28) .
p
.........................................................................................................
Supplementary Problems 7
LAW O F Q UA D R AT I C R E C I P R O C I T Y ( LQ R ) ( 3 1 5 – 3 2 9 ) 329
7.9. *(i) Find the primes p > 3 for which 7.15. Let p be an odd prime. Prove that
the square root of 3 (mod p) exists. the Legendre symbol
(p+5)(p−1)
(ii) Factorize the following integers: −2
( ) = (−1) 8 .
(a) 3062 − 3 = 93 633 p
(b) 2142 − 3 = 45 793 Determine whether −2 is a quadratic
(c) 6022 − 3 = 362 401 residue of the prime 1 000 003.
7.10. Determine particular solutions of the 7.16. **Let p be an odd prime. Prove that
quadratic Diophantine equations: x4 ≡ − 1 (mod p) has a solution
(a) x 2 + 11y = 5 ⇔ p ≡ 1 (mod 8).
(b) x 2 + 23y = 2 Factorize the following integers:
(c) x 2 + 53y = −1 (a) 124 + 1 = 20 737
7.11. *Without using Dirichlet’s Theorem (b) 224 + 1 = 234 257
prove the following: (c) 504 + 1 = 6 250 001
(a) There are infinitely many primes 7.17. (i) Prove that for prime p > 3 we
of the form 8k + 3. [Hint: Consider have
2
N = [3 × 5 × 7 × ⋯ × (2n + 1)] + 2.] 12 1 if p ≡ ±1 (mod 12)
(b) There are infinitely many primes ( )={ .
p −1 if p ≡ ±5 (mod 12)
of the form 8k − 3. [Hint: Consider
2
N = [3 × 5 × 7 × ⋯ × (2n + 1)] + 4.] (ii) Factorize the following integers:
7.12. Show that if p is a prime of the form (a) 1512 − 12 = 22 789
4k + 3 and a, b are integers such that (b) 20032 − 12 = 4 011 997
a2 + b2 ≡ 0 (mod p), then 7.18. (i) Prove that every primitive root of
a ≡ b ≡ 0 (mod p). odd prime p is a quadratic
non-residue of p.
7.13. Express the following primes as the
sum of two squares a2 + b2 : *(ii) Prove that there is a quadratic
(a) 313 (b) 1237 (c) 1249 non-residue of odd prime p which is
We will prove in Theorem (8.3) in not a primitive root of p.
the next chapter that if a prime p 7.19. *Let a be a quadratic residue of an
satisfies p ≡ 1 (mod 4) then we can odd prime p. Prove that square roots
write the prime as the sum of two of a (mod p) are given by ±r n where
squares. r is a primitive root of p and n is
7.14. Let p be an odd prime. Show that
some positive integer.
there are integers a, b such that 7.20. *Show that the non-linear
p = a2 + 2b2 ⇒ p ≡ 1 or 3 (mod 8). Diophantine equation x3 − 5 = y 2
Also, in the next chapter we will has no solution.
show that if p ≡ 1 or 3 (mod 8) then 7.21. Prove that −5 is a quadratic residue
2
p = a + 2b . 2 for the primes p satisfying
Express the following primes as p ≡ 1, 3, 7, 9 (mod 20).
a2 + 2b2 . [Hint: Use the result of Exercises 7.4,
(a) 211 (b) 1019 (c) 1249 question 18.]
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
..............................................................................................................................
Non-Linear Diophantine
8 Equations
..............................................................................................................................
In Chapter 2 (Section 2.3.5) we discussed which primes could be written as the sum of two
squares. In this chapter we will prove one of the most amazing theorems in mathematics:
that every prime p which satisfies p ≡ 1 (mod 4) can be written as the sum of two squares,
that is
p = a2 + b2 .
Also in this section we extend this to which positive integers (not only primes) can be con-
verted into a sum of two squares.
In the next section we show that every positive integer n can be written as a sum of four
squares: n = a2 + b2 + c2 + d2 .
In the last section we examine the quadratic Diophantine equation x2 − Ny2 = c which
is closely related to x2 − py = c ( p is an odd prime), investigated in the last chapter.
Examples are
Consider the first of these Pythagorean triples 32 + 42 = 52 . From this we can show:
2 2 2
(3n) + (4n) = (5n) where n is any positive integer.
x = 2mn, y = n2 − m2 , and z = n2 + m2
where n > m, mn is odd and m, n are relatively prime. In the special case when m = 1 we
have the Pythagorean triples x = 2n, y = n2 − 1, and z = n2 + 1.
No. Therefore, we conclude that not every positive integer can be expressed as a sum of two
squares, as we simply cannot write 3 as a sum of two squares.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S U M O F T W O S Q UA R E S ( 3 3 1 – 3 4 3 ) 333
Table 8.1
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
Clearly it is not all the integers, nor just the odd or even ones.
So what is the pattern?
Well the squares are definitely part of sum of two squares because we can write a square
number, n2 , as n2 = n2 + 02 . Also n2 + 1 can be written as sum of two squares because
n2 + 1 = n2 + 12 . However, these two, n2 and n2 + 1, do not capture all of the highlighted
numbers in Table 8.1. Actually there is no simple pattern for which numbers can be ex-
pressed as a sum of two squares. We will give a criterion to test which integers can be con-
verted into a sum of two squares in result (8.5) later in this section.
To convert a given integer into a sum of two squares we need to use the algebraic identity
discussed in the next subsection.
Two expressions are equal for all values of the variables; for example,
2
(x + y) = x2 + 2xy + y2 and cos2 (𝜃) + sin2 (𝜃) = 1 are identities.
The following identity converts a product into a sum and is called the Conversion or Two
Squares Identity:
Proof.
Expanding the left-hand side gives
We use this identity (8.1) to convert a product (factorized) into a sum, as the next example
demonstrates.
Example 8.1
Solution
You may have noticed an obvious solution is 152 = 225, so we have 225 = 152 + 02 .
Another representation can be found by factorizing 225 and then converting this product into a sum
by the above Conversion Identity:
225 = 5 × 45.
We can express 5 as 5 = 12 + 22
and 45 = 9 + 36 = 32 + 62 . By putting these into the above identity
(8.1) with a = 1, b = 2, c = 3, and d = 6 we obtain
225 = 5 × 45
= (12 + 22 ) × (32 + 62 )
2 2
= ([1 × 3] − [2 × 6]) + ([1 × 6] + [2 × 3]) [Converting product to sum (8.1)]
2
= (−9) + 122 = 92 + 122 .
Hence converting 225 into sum of two squares gives 225 = 92 + 122 .
Note that converting an integer into a sum of two squares does not give a unique rep-
resentation because 225 = 152 + 02 = 92 + 122 . However, if the given integer is prime then
the representation is unique as the sum of two squares, which we will show later.
First we factorize the given integer and then apply the identity (8.1) repeatedly to convert
the product into a sum, as the next example demonstrates.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S U M O F T W O S Q UA R E S ( 3 3 1 – 3 4 3 ) 335
Example 8.2
Solution
The prime decomposition of 8177 is
8177 = 13 × 17 × 37.
13 = 22 + 32 , 17 = 12 + 42 and 37 = 12 + 62 .
13 × 17 = (22 + 32 ) × (12 + 42 )
2 2
= ([2 × 1] − [3 × 4]) + ([2 × 4] + [3 × 1]) [By (8.1)]
2
= (−10) + 112 = 102 + 112 .
We have converted the product into a sum of two squares: 13 × 17 = 102 + 112 . Applying the identity
(8.1) again to 13 × 17 = 102 + 112 and 37 = 12 + 62 yields
This sum of squares 562 + 712 representation of 8177 is not unique. There are three other
ways of representing 8177 as a sum of two squares. Actually, here are the four sum of square
representations of 8177:
13 ≡ 17 ≡ 37 ≡ 1 ( mod 4) ,
What is special about these integers, 225 and 8177, that we can write them as a sum of two squares?
Their prime decomposition gives primes p which satisfy p ≡ 1 ( mod 4). We now prove that
if the prime p satisfies p ≡ 1 ( mod 4) then it can be written as the sum of two squares. You
are asked to show that this sum of squares representation of prime p is unique in the exer-
cises. First we need a lemma.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Lemma (8.2). If prime p ≡ 1 (mod 4) then there exist positive integers x and y such that
x2 + y2 = kp where k < p and it is a positive integer.
Proof.
See Exercises 8.1, question 10.
Theorem (8.3). Every prime p satisfying p ≡ 1 ( mod 4) can be written as the sum of two
squares.
This says that all the primes that leave a remainder of 1 when divided by 4 can be written
as the sum of two squares.
To prove this, we need to use the Well-Ordering Principle (WOP) which was given in the
Introductory Chapter:
WOP: Every non-empty subset of positive integers has a least element.
This is a challenging and long proof.
Proof.
Let p ≡ 1 ( mod 4). By the previous lemma, there exist positive integers x and y such that
By the Well-Ordering Principle (WOP) let m be the least of these k’s, that is
How?
a2 + b2 = mn. (∗∗)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S U M O F T W O S Q UA R E S ( 3 3 1 – 3 4 3 ) 337
Now using the Conversion Identity (8.1) on the left-hand side yields
Examining both terms inside the brackets (bx − ay) and (by + ax):
bx − ay ≡ yx − xy ≡ 0 ( mod m) because a ≡ x ( mod m) and b ≡ y ( mod m) .
Similarly,
by + ax ≡ yy + xx ≡ y2 + x2 ≡ 0 ( mod m) [By (∗)].
Thus both bx − ay and by + ax are multiples of m, which implies that we can divide (†) by
m2 and get the following sum of two squares:
2 2
by + ax bx − ay
( ) +( ) = np. (††)
m m
m m
From the earlier inequality − < a, b ≤ we have
2 2
m 2 m 2 m2
a2 + b2 ≤ ( ) +( ) = .
2 2 2
By (∗∗) and the above inequality it follows that
m2 m
a2 + b2 = mn ≤ ⇒ n≤ ⇒ n < m. (‡)
2 2
If n = 0 then we have our result.
Why?
From (∗∗)
m2 | (x2 + y2 ) ⇒ m2 | mp ⇒ m | p .
⏟
By (∗)
We know that m < p because m is the least of k’s and 0 < k < p. The only divisors of a prime
p are 1 and p. Therefore we have m = 1, which is our required result.
If n is a positive integer, then from (††) we have that np is the sum of two squares and (‡)
shows that n < m. This is a contradiction.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Why?
Because m was the least positive integer which is the sum of two squares, and now we have
found a smaller positive integer n. Our supposition that m > 1 must be wrong, so m = 1
which implies x2 + y2 = mp = p. Hence p ≡ 1 ( mod 4) can be written as the sum of two
squares.
A prime p that satisfies p ≡ 1 ( mod 4) can be expressed as the sum of two squares.
In the exercises we will prove that the converse is also true, and we have uniqueness:
Theorem (8.4). An odd prime p can be written as sum of two squares uniquely ⇔
p ≡ 1 ( mod 4) .
Proof.
See Exercises 8.1, question 22.
The conversion of a prime number to sum of two squares is unique. On the other hand,
the conversion of a composite number may not give a unique sum of two squares, as we
observed in Example 8.1.
The next subsection sets up a criterion for testing which integers (not only primes) can
be written as a sum of two squares.
Now we prove the criterion to test which integers can be converted into sum of two squares:
In Exercises 8.1, question 11 you are asked to show that any integer m > 1 (if m = 1 then
m = 12 + 02 ) can be written as
m = p1 × p2 × ⋯ × pr × N2 .
Proof.
Let m = p1 × p2 × ⋯ × pr × N2 . If we can prove that the product p1 × p2 × ⋯ × pr can be
converted into sums of two squares then we are done.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S U M O F T W O S Q UA R E S ( 3 3 1 – 3 4 3 ) 339
Why?
m = ( p1 × p2 × ⋯ × pr ) × N2
= (a2 + b2 ) × N2
2 2
= (aN) + (bN) .
How?
By mathematical induction.
The base case r = 1 holds because by Theorem (8.3):
If n = p where p ≡ 1 (mod 4) then we can write n as the sum of two squares.
Assume this is also true for the product of k primes, that is r = k:
2 2
p1 × p2 × ⋯ × pk × pk+1 = (xk+1 ) + (yk+1 ) .
Recall we are given that the prime pk+1 is either 2 = 12 + 12 or pk+1 ≡ 1 ( mod 4). In either
case we can write this prime as the sum of two squares (by Theorem (8.3)):
pk+1 = x 2 + y 2 .
We can convert this product (x2k + y2k ) × (x 2 + y 2 ) into a sum of two squares by applying
the Conversion Identity (8.1):
2 2
(a2 + b2 ) × (c2 + d2 ) = (ac − bd) + (ad + bc) .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Example 8.3
Solution
We first factorize 1352. Since 1352 is even, so 2 is a factor; actually, 8 = 23 is a factor:
1352 = 23 × 132 = ⏟
2 ×⏟
(2⎵×
⏟⎵
2 2
⏟ = 2 × 26 .
13)
=p1 =N
1352 = 2 × 262
= (12 + 12 ) × 262 = 262 + 262 .
Example 8.4
Solution
Factorizing 360 gives 360 = 23 × 32 × 5. Rewriting this in the format of the Sum of Two Squares
Theorem (8.5), m = p1 × p2 × ⋯ × pr × N2 , we have
360 = 23 × 32 × 5 = ⏟
2 × ⏟
5 × (2
⏟⏟⏟× 3)2 . (∗)
=p1 =p2 =N
Since the primes p1 = 2 and p2 = 5 ≡ 1 (mod 4), so we can express 360 as the sum of two squares.
First we convert the product of these two primes:
2 × 5 = 10 = 12 + 32 .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S U M O F T W O S Q UA R E S ( 3 3 1 – 3 4 3 ) 341
Hence 360 = 62 + 182 . (This representation is unique because only 5 ≡ 1(mod 4)).
Example 8.5
Solution
Let us first see if it is possible to express 255 as the sum of two squares. Factorizing 255 yields 3 × 5 × 17.
Since one of the primes is 3 ≡ 3 (mod 4), so 255 cannot be written as a sum of two squares.
Is there a pattern to the 57 numbers which are not highlighted (cannot be expressed as a sum of two
squares) in Table 8.1?
If n ≡ 3 (mod 4) then n cannot be written as a sum of two squares. For example, in the table
we see that if n = 3, 7, 11, 15, ⋯ , which are all congruent to 3 modulo 4 and these cannot
be written as a sum of two squares,
We need to prove this holds for all n such that n ≡ 3 (mod 4).
By contradiction.
Proof.
Let n ≡ 3 (mod 4). Suppose we can express n as a sum of two squares: n = a2 + b2 .
By Exercises 1.2, question 2:
The square of any integer is of the form 4m or 4m + 1.
Applying this, we have a2 ≡ 0, 1 ( mod 4) and b2 ≡ 0, 1 ( mod 4).
Adding these together gives
n = a2 + b2 ≡ 0,
⏟1 + 0,
⏟1 ≡ 0, 1, 2 ( mod 4) .
=a2 =b2
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
For example, 27 ≡ 3 ( mod 4) cannot be written as a sum of two squares. This congruence
n ≡ 3 ( mod 4) does not pick up all the integers which cannot be written as a sum of two
squares. For example, from Table 8.1 we have that composite number 69 cannot be expressed
as a sum of two squares, but 69 ≡ 1 ≢ 3 ( mod 4).
Note that 69 is not a prime, otherwise by Theorem (8.3) we would be able to write it as a
sum of two squares. Actually 69 = 82 + 22 + 12 ; we need three squares to write 69.
The prime factors of 69 = 3 × 23 and
3 ≡ 23 ≡ 3 (mod 4) .
Sometimes to test whether a given integer can be written as the sum of two squares it is
easier to use the converse of the Sum of Two Squares Theorem (8.5), which is:
Proof.
See Exercises 8.1, question 24.
From the last three results (8.5), (8.6), and (8.7), we have the following corollary:
Proof.
See Exercises 8.1, question 25.
This Corollary says that if p ≡ 3 ( mod 4) is present to an odd power in the prime factor-
ization of n then n cannot be written as a sum of two squares. This is an easy check to see
which numbers can be written as a sum of two squares.
However, if the prime p ≡ 3 ( mod 4) appears to an even index then the number n can be
written as a sum of two squares. For example, 7 ≡ 3 ( mod 4) and
245 = 5 × 72 = 142 + 72 .
S U M O F T W O S Q UA R E S ( 3 3 1 – 3 4 3 ) 343
Summary
In this section we have converted a given integer into sum of two squares.
The criterion for testing whether a given integer can be written as a sum of two squares is given by:
Let m = p1 × p2 × ⋯ × pr × N2 provided every prime pj = 2 or pj ≡ 1 (mod 4).
EXERCISES 8.1
.........................................................................................................
S U M O F F O U R S Q UA R E S ( 3 4 4 – 3 5 2 ) 345
Why isn’t the main title of this Section ‘8.2 Sum of Three Squares’?
Clearly if we extend our sum to three squares then this will cover more than the two squares,
because we could use 02 as our third square to include all the sums of two squares. The
following integers need three non-zero squares:
3 = 12 + 12 + 12 , 6 = 22 + 12 + 12 , 14 = 12 + 22 + 32 , 19 = 12 + 32 + 32 , . . .
Again all the positive integers cannot be written as a sum of three squares because
7 = 22 + 12 + 12 + 12 .
For 7 we need four squares. The other problem with three squares is that there is no three-
square identity like the one we had for two squares given in the last section:
2 2
(8.1) (a2 + b2 ) × (c2 + d2 ) = (ac − bd) + (ad + bc) .
This means we cannot convert a product of three squares into a sum of three squares:
(a2 + b2 + c2 ) × (x2 + y2 + z2 ) ≠ d
⏟⎵⎵⎵⎵⎵⎵⎵⎵⏟⎵⎵⎵⎵⎵⎵⎵⎵⏟ ⏟⎵+
2 e2 +
⎵⏟⎵ ⎵⏟f2 [Not Equal] .
Product of Three Squares Sum of Three Squares
11 = 32 + 12 + 12 ; 13 = 32 + 22 + 02 .
However
143 = 11 × 13 ≠ x2 + y2 + z2 [Not Equal] .
2 2 2 2
Actually, 143 = 11 + 3 + 3 + 2 . Furthermore, we also have the following result:
Proposition (8.9). A positive integer which looks like 4n (8m + 7) cannot be expressed as a
sum of three squares.
Proof.
See Exercises 8.2, question 12.
No, because if n ≡ 3 ( mod 8) then we can write this as a sum of three positive squares. You
are asked to prove this in Supplementary Problems 8, question 8.6.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
However, for both the above reasons, no three-square identity and Proposition (8.9),
converting a given integer into sum of three squares is an impossible task.
2 2
(a2 + b2 + c2 + d2 ) × (x2 + y2 + z2 + w2 ) = (ax + by + cz + dw) + (ay − bx + cw − dz)
2 2
+ (az − bw − cx + dy) + (aw + bz − cy − dx) .
This identity converts product of four squares into sum of four squares.
Proof.
See Exercises 8.2, question 13.
We use this four-square identity to convert a given positive integer into sum of four
squares, as the following example demonstrates.
Example 8.6
Solution
(i) First we factorize 15 into 3 × 5. Writing each of these integers, 3 and 5, as sum of four squares
gives
3 = 12 + 12 + 12 + 02 and 5 = 22 + 12 + 02 + 02 .
Using the above Sum of Four Squares Identity (8.10) to convert from product to sum,
(12 + 12 + 12 + 02 ) × ⏟⎵⎵⎵⎵⏟⎵⎵⎵⎵⏟
3 × 5 = ⏟⎵⎵⎵⎵⏟⎵⎵⎵⎵⏟ (22 + 12 + 02 + 02 ) [Product of four squares]
=3 =5
2 2
= ([1 × 2] + [1 × 1] + [1 × 0] + [0 × 0]) + ([1 × 1] − [1 × 2] + [1 × 0] − [0 × 0])
2 2
+ ([1 × 0] − [1 × 0] − [1 × 2] + [0 × 1]) + ([1 × 0] + [1 × 0] − [1 × 1] − [0 × 2])
2 2 2
= 32 + (−1) + (−2) + (−1) = 32 + 12 + 22 + 12 [Sum of four squares] .
S U M O F F O U R S Q UA R E S ( 3 4 4 – 3 5 2 ) 347
(ii) Note that 105 = 7 × 15. Applying (8.10) to convert the product 105 = 7 × 15 into sum of four
squares gives:
(32 + 22 + 12 + 12 ) × ⏟⎵⎵⎵⎵⏟⎵⎵⎵⎵⏟
15 × 7 = ⏟⎵⎵⎵⎵⏟⎵⎵⎵⎵⏟ (22 + 12 + 12 + 12 ) [Product of four squares]
=15 by part (i) =7
2 2
= ([3 × 2] + [2 × 1] + [1 × 1] + [1 × 1]) + ([3 × 1] − [2 × 2] + [1 × 1] − [1 × 1])
2 2
+ ([3 × 1] − [2 × 1] − [1 × 2] + [1 × 1]) + ([3 × 1] + [2 × 1] − [1 × 1] − [1 × 2])
2
= 102 + (−1) + 02 + 22 = 102 + 22 + 12 + 02 [Sum of four squares] .
Thus 105 = 102 + 22 + 12 + 02 . This shows we only need three non-zero squares for 105.
Sometimes it is easier to tackle this conversion by trial and error rather than using the
four-square identity. For example, we know 105 is 100 + 5 and 100 = 102 and 5 = 22 + 12 ,
so 105 = 102 + 22 + 12 + 02 .
In order to prove that every positive integer can be written as the sum of four squares we
need to use modular arithmetic.
First, we establish Lemma (8.11) and to prove this we need to use the pigeonhole principle
which was defined in the Introductory Chapter:
The Pigeonhole Principle
If k + 1 or more objects are placed into k boxes, then at least one of the boxes contains
two or more of these objects.
Lemma (8.11). Let p be an odd prime. There are integers x and y such that
p−1
x2 + y2 ≡ −1 ( mod p) where 0 ≤ x, y ≤ .
2
Before we provide a proof of this result, here are some numerical examples of this:
(a) Some of the solutions of x2 + y2 ≡ −1 ( mod 13) which lie in the stipulated condi-
p − 1 13 − 1
tion 0 ≤ x, y ≤ = = 6 are:
2 2
{x = 5, y = 0} , {x = 3, y = 4} , {x = 4, y = 3} ( mod 13) .
{x = 1, y = 7} , {x = 0, y = 4} , {x = 5, y = 5} ( mod 17) .
{x = 1, y = 3} , {x = 3, y = 1} , {x = 4, y = 4} ( mod 11) .
Proof.
We need to show that for every odd prime p the given quadratic congruence
p−1
x2 + y2 ≡ −1 ( mod p) has solutions x and y, such that 0 ≤ x, y ≤ .
2
By transposing this given equation x2 + y2 ≡ −1 ( mod p) we obtain
x2 ≡ −1 − y2 ( mod p) .
Splitting the two sides of this equation into two sets S and T yields
p−1 2 p−1
S = {02 , 12 , 22 , ⋯ , ( ) } [Subsituting x = 0, 1, 2, 3, ⋯ , into x2 ]
2 2
p−1 2
T = {−1 − 02 , −1 − 12 , −1 − 22 , ⋯ , −1 − ( ) } [Substituting y = 0, 1, 2, ⋯ ,
2
p−1
into − 1 − y2 ]
2
Why not?
p−1 2 p−1
Card (S) = Card {02 , 12 , 22 , ⋯ , ( ) } = 1+ .
2 2
p−1
Similarly, the number of integers in set T is Card (T) = 1 + . Therefore, there are
2
p−1 2+p − 1
Card (S) +Card (T) = 2 (1+ ) =2( ) = p + 1 integers in S ∪ T (S or T).
2 2
By the pigeonhole principle (defined above) there must be at least one integer in S which
is congruent to an integer inT because there are only p integers modulo p, but we have p + 1
integers in S ∪ T. Therefore, there are integers x0 and y0 such that
p−1
x20 ≡ −1 − y20 ( mod p) where 0 ≤ x0 , y0 ≤ .
2
This completes our proof.
S U M O F F O U R S Q UA R E S ( 3 4 4 – 3 5 2 ) 349
Example 8.7
By writing out the two sets given in the previous proof, determine x and y such that
x2 + y2 ≡ −1 ( mod 19) where 0 ≤ x, y ≤ (19 − 1) /2 = 9.
Solution
Transposing the given equation,
x2 ≡ −1 − y2 ( mod 19) .
p − 1 19 − 1
In this case we have p = 19, so = = 9. Therefore, there are 9 + 1 = 10 integers in each
2 2
set (20 altogether in S or T);
S = {02 , 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 } ≡ {0, 1, 4, 9, 16, 25, 36, 49, 64, 81} (mod 19)
T = {−1 − 02 , −1 − 12 , −1 − 22 , −1 − 32 , −1 − 42 , −1 − 52 , −1 − 62 , −1 − 72 , −1 − 82 , −1 − 92 }
≡ {−1, −2, −5, −10, −17, −26, −37, −50, −65, −82} (mod 19) .
The least non-negative residues modulo 19 of these sets, S and T, are given by
There are five integers 1, 7, 9, 11, and 17, which are in both sets S′ and T ′ . If we take the integer 1
which is common to both these sets, S′ and T ′ , then from the set S this corresponds to 12 , the second
element in S. The integer 1 is the seventh element in T ′ , so it corresponds to the seventh element in
the set T which is −1 − 62 . Therefore, solving x2 ≡ −1 − y2 (mod 19) gives:
Note that the solutions in the above example to x2 + y2 ≡ −1 ( mod 19) are only the ones
which satisfy 0 ≤ x, y ≤ 9. There are other solutions to this equation x2 + y2 ≡ −1 ( mod 19)
which you are asked to find in Exercises 8.2, question 6.
Corollary (8.12). Let p be an odd prime. There exists a positive integer m with m < p such
that mp can be written as a sum of four squares.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
This statement claims that the product of any odd prime p with a multiple m such that
0 < m < p can be written as a sum of four squares.
Proof.
We need to prove that there are integers x, y, z, and w which satisfy
x2 + y2 + z2 + w2 = mp.
p−1
By the previous Lemma (8.11) there exist integers x and y such that 0 ≤ x, y ≤ and
2
x2 + y2 ≡ −1 ( mod p) ⇔ x2 + y2 + 1 ≡ 0 ( mod p)
⇔ x2 + y2 + 1 = mp for some integer m.
p−1
Since 0 ≤ x, y ≤ , so
2
2 2
2 2
(p − 1) (p − 1)
x +y +1 ≤ + +1
4 4
2
(p − 1) p2
= +1 < + 1 < p2 .
2 2
Thus, we can write the above x2 + y2 + 1 = mp as
x2 + y2 + 1 = x2 + y2 + 12 + 02 = mp < p2 .
Therefore, there is an integer m such that x2 + y2 + 12 + 02 = mp where m < p.
This completes our proof.
Example 8.8
Determine the values of m as defined in the previous corollary for modulo 19 and convert mp into sum
of four squares.
Solution
In the previous example we solved x2 + y2 ≡ −1 ( mod 19) and obtained the solutions
{x = 1, y = 6} , {x = 8, y = 7} , {x = 3, y = 3} , {x = 7, y = 8} , {x = 6, y = 1} (mod 19) .
x2 + y2 + 12 + 02 = 12 + 62 + 12 + 02 = 38 = 2 × 19 implies m = 2
x2 + y2 + 12 + 02 = 82 + 72 + 12 + 02 = 114 = 6 × 19 implies m = 6
x2 + y2 + 12 + 02 = 32 + 32 + 12 + 02 = 19 = 1 × 19 implies m = 1.
The remaining two solutions have already been covered by the symmetric nature of x and y, because
Hence converting 38, 114, and 19 into sum of four squares gives
38 = 62 + 12 + 12 + 02 , 114 = 82 + 72 + 12 + 02 and 19 = 32 + 32 + 12 + 02 .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
S U M O F F O U R S Q UA R E S ( 3 4 4 – 3 5 2 ) 351
Example 8.9
Solution
First we factorize 133 = 7 × 19. In the previous example we converted 19 into sum of four squares:
19 = 32 + 32 + 12 + 02 .
Remember this identity converts a product of four squares into a sum of four squares.
Applying this identity to the product 133 = 7 × 19 gives
First we state that every prime can be expressed as the sum of four squares.
Then we prove the more general statement:
Every positive integer can be expressed as the sum of four squares.
Theorem (8.13). Every prime can be expressed as the sum of four squares.
Proof.
See Exercises 8.2, question 14.
Lagrange’s Sum of Four Squares Theorem (8.14). Every positive integer can be expressed
as the sum of four squares.
Using the previous Theorem (8.13) and Sum of Four Squares Identity (8.10).
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Proof.
If n = 1 then 1 = 12 + 02 + 02 + 02 which means we have our result.
Let n > 1. By the Fundamental Theorem of Arithmetic (2.5):
Integer n > 1 is either a prime or can be written as the product of primes:
k k k k
n = p11 × p22 × p33 × ⋯ × pl l .
Summary
In this section we have shown that every positive integer can be converted into a sum of four squares.
We can use the Sum of Four Squares Identity (8.10) to convert from a product to a sum of four squares.
EXERCISES 8.2
6. Find all the incongruent solutions of 9. *Let n > 169 be an integer. Show that
x2 + y2 ≡ −1 ( mod 19). [See n can be written as the sum of five
Example 8.7.] positive squares. [Hint: Consider
n = m + 169.]
7. Determine all the incongruent
solutions of x2 + y2 ≡ −1 ( mod 13). 10. Show that expressing a positive integer
into sum of four squares is not
8. If x = a2 + b2 + c2 + d 2 , show that
unique.
2 2 2
2x = (a + b) + (a − b) + (d − c)
2 11. Prove that 8m + 7 cannot be
+ (c + d) . written as a sum of three
Given 1984 = 402 + 162 + 82 + 82 , squares.
convert 12. Prove Proposition (8.9).
(i) 3968 = 2 × 1984 into sum of four
squares. 13. Prove Sum of Four Squares Identity
1984 (8.10).
(ii) 992 = into sum of four
2
squares. [Hint: Use part (i).] 14. ***Prove Theorem (8.13).
.........................................................................................................
8.3.1 Brahmagupta
The great Indian mathematician and astronomer Brahmagupta (598–670 AD) made the
following claim:
‘A person who can solve the equation x2 − 92y2 = 1 within a year is a mathematician.’
11512 − 92 (1202 ) = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
In the last chapter we solved x2 − py = a where p is an odd prime for integer solutions
(see Supplementary Problems 7, question 7.7). Now we explore x2 − Ny2 = 1 and again we
are only interested in integer solutions. We will see later in this section that the ratio of
x
solutions provides good rational approximations for √N.
y
In this section our aim is to find the least positive solution to equations of the type
x2 − Ny2 = 1, and from this least positive solution we can find all the other solutions.
The general equation of this type x2 − Ny2 = 1 where N is a non-square (or square-free)
integer is called Pell’s equation, named after the British mathematician, John Pell.
John Pell (1611–85) was born in Sussex, England and by the time he was six years old
he had become an orphan. However, even after such a difficult upbringing he managed to
secure a place at Trinity College Cambridge in 1624, aged only 13.
After leaving Cambridge he became a school teacher. In 1632 he married and had eight
children (four boys and four girls).
John Pell worked in algebra and number theory, producing a table of factors of positive
integers up to 100 000.
As discussed above, Pell’s equation x2 − Ny2 = 1 was first examined by Brahmagupta but
Euler attributed this equation to Pell. So Pell’s equation is a misnomer. There are many
misnomers in mathematics, but perhaps the most famous is Pythagoras’s Theorem, as this
was known to the Babylonians, Egyptians, Chinese, and Indians long before Pythagoras
was born.
We will continue to use the misnomer Pell’s equation, as most of the literature on number
theory tends to use this.
Example 8.10
x2 − 2y2 = 1.
Solution
Transposing the given equation yields
x2 = 1 + 2y2 ⇔ x = √1 + 2y2 .
One way of solving this equation x = √1 + 2y2 is to trial different integers for y = 1, 2, 3, 4, … and then
stop when 1 + 2y2 is a square number.
Remember we are looking for integer solutions. Substituting y = 1 is not going to work because
x = √1 + 2 = √3 and √3 is not an integer.
Substituting y = 2 into the above equation x = √1 + 2y2 gives
x = √1 + 2y2 = √1 + 2(22 ) = √9 = 3.
By examining the graph of x2 − 2y2 = 1 we can see there are infinitely many solutions to
this equation because all the points on the graph x2 − 2y2 = 1 are solutions, but we are only
interested in (positive) integer solutions (lattice points):
y
x2 –2y2 = 1 (3, 2)
(–3, 2)
x2 – 2y2 = 1 x
(–3, –2)
(3, –2)
Figure 8.2
By positive solutions we mean that both integers x and y that satisfy Pell’s equation
x2 − Ny2 = 1 are positive. In the above graph we only need to consider the point (3, 2).
Why?
Because from this positive solution (3, 2) we can find the other solutions:
(−3, 2) , (3, −2) and (−3, −2) .
In general, if (x, y) is a positive integer solution then so are
(−x, y) , (x, −y) , and (−x, −y) solutions.
Why?
2 2
Because squaring (−x) = +x2 and (−y) = +y2 satisfies
x2 − Ny2 = 1.
As stated above, Brahmagupta was the first to look at these types of equations.
17 3363
− √8 = 0.0049 (2sf) and − √8 = 0.000 000 13 (2sf).
6 1189
For Pell’s equation x2 − Ny2 = 1 the integer N > 1 and it is not a square number, or equiv-
alently we say that N is square-free.
If N = 0 then our equation x2 − Ny2 = 1 becomes x2 = 1 which implies x = ±1, and y is any
positive integer.
If N is a square number, then we only have the trivial solutions x = ±1,
y = 0. You are asked to show this in Exercises 8.3, question 8.
We are interested in non-trivial solutions of x2 − Ny2 = 1, which means we need N > 1
and N is square-free.
Why?
1
http://www-groups.dcs.st-and.ac.uk/history/Biographies/Brahmagupta.html.
2
https://nrich.maths.org/5961.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
x + y √N = 3 + 2√2.
We say that the irrational number 3 + 2√2 produces a solution of x2 − 2y2 = 1 because
(3 + 2√2) (3 − 2√2) = 9 − (4 × 2) = 1.
x + y √N = a + b √N ⇔ x = a, y = b.
Proof.
(⇐). Clearly if x = a, y = b then
x + y √N = a + b √N.
y √N − b √N = a − x
a−x
(y − b) √N = a − x implies √N = .
y−b
a−x
This √N = implies that √N is rational. However, we are given that N is square-free,
y−b
therefore √N is irrational. We have a contradiction to our supposition y ≠ b, so y = b.
Proof.
See Exercises 8.3, question 10.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Proof.
We are given that r = a + b√N produces a solution of x2 − Ny2 = 1, so by substituting x = a
and y = b we have:
a2 − Nb2 = 1. (∗)
Converting the left-hand side into the difference of two squares gives
Dividing both sides of this r (a − b √N) = 1 by r gives r−1 = a − b√N. We can write
r−1 = a − b√N = a + (−b) √N. By the symmetric nature of quadratics we have
2
a2 − Nb2 = a2 − N (−b) =
⏟ 1.
By (∗)
y (1151 , 120)
120 x2 – 92y2 =1
60
x
200 400 600 800 1000 1200
–60
Figure 8.3
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Example 8.11
x2 − 5y2 = 1.
Also show that r−1 produces a solution.
Solution
Transposing the given equation x2 − 5y2 = 1, we have
By trialling integer values for y we have for y = 4 (trialling integers y = 1, 2, 3 will not give an integer
for x):
x = √1 + 5 (42 ) = √81 = 9.
Hence a solution of x2 − 5y2 = 1 is x = 9 and y = 4. Therefore, r = 9 + 4√5.
From the previous proposition we have
Note that the reciprocal r−1 = 9 − 4√5 gives us (9, −4) which is negative y, but we are
interested in positive integer solutions because we can find this (9, −4) from (9, 4).
Proposition (8.18). If the irrational numbers r = a + b√N and s = c + d√N produce solu-
tions of Pell’s equation x2 − Ny2 = 1 then so does the product r × s.
Proof.
We are given that r = a + b√N and s = c + d√N produce solutions of x2 − Ny2 = 1. Con-
sider the product r × s:
r × s = (a + b√N) (c + d√N)
Since we are given that r = a + b√N and s = c + d√N produces solutions of x2 − Ny2 = 1, so
a2 − Nb2 = 1 and c2 − Nd2 = 1 respectively. Substituting this a2 − Nb2 = 1 and c2 −Nd2 = 1
into (∗∗) gives
𝛼2 − N𝛽 2 = 1 × 1 = 1.
Example 8.12
Check that both r = 5 + 2√6 and s = 47 525 + 19 402√6 produce solutions of Pell’s equation,
x2 − 6y2 = 1.
Solution
First, checking that r = 5 + 2√6 gives a solution to x2 − 6y2 = 1. Let x = 5, y = 2 so
x2 − 6y2 = 52 − (6 × 22 ) = 1.
47 5252 − (6 × 19 4022 ) = 1.
Hence the product r × s = 470 449 + 192 060√6 produces a solution of x2 − 6y2 = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Recall that ratio of the solution x/y provides a good approximation to √6:
470 449
− √6 = 5.534 × 10−12 .
192 060
The discrepancy between 470 449/192 060 and √6 is just over five and a half parts in a
trillion.
Example 8.13
x2 − 6y2 = 1.
Solution
From Example 8.12 we have that r = 5 + 2√6 produces a solution of x2 − 6y2 = 1. Consider the
product r × r:
2
r × r = r2 = (5 + 2√6)
2
= 52 + (2 × 5 × 2√6) + (2√6) = 25 + 20√6 + (4 × 6) = 49 + 20√6.
By the previous Proposition (8.18) we have that the product r × r = 49 + 20√6 produces a solution to
the given equation x2 − 6y2 = 1. Check that x = 49, y = 20 does indeed give a solution.
From this example x2 − 6y2 = 1, we can see from the graph below that r = 5 + 2√6 and
r2 = 49 + 20√6 produce positive integer solutions:
(49, 20)
20
10 (5, 2) x2 – 6y2 = 1
x
10 20 30 40 50
Figure 8.4
We have shown in the previous example that if r = a + b√N produces a solution then so
does r2 .
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Yes, because we have proven that both r 2 and r produce a solution so by Proposition (8.18)
their product r 2 × r = r 3 also produces a solution.
Similarly, r 4 , r 5 , r 6 , ⋯ all produce solutions of x2 − Ny2 = 1.
In Exercises 8.3, question 14 you are asked to show that all the positive integer solutions
n
of x2 − 6y2 = 1 are given by r n = (5 + 2√6) where n = 1, 2, 3, ⋯.
Proof.
See Exercises 8.3, question 11.
Proposition (8.19) implies that there are infinitely many solutions of Pell’s equation. We
can use this proposition to find other solutions of Pell’s equation x2 − Ny2 = 1, as the next
example demonstrates.
Example 8.14
Solution
From the previous example we already have that r 2 = 49 + 20√6 yields a solution to the given equa-
tion. Now r 3 = r 2 × r, therefore
x 2 − 6y 2 = 4852 − (6 × 1982 ) = 1.
First, we establish the least positive integer solution of Pell’s equation x2 − Ny2 = 1 which
is called the fundamental or seed solution. In this subsection we will show that from this
fundamental solution we can generate all the other solutions to Pell’s equation.
We define the fundamental (seed) solution or least positive solution x0 , y0 of x2 − Ny2 = 1,
which satisfies x0 < x ′ and y0 < y ′ where x ′ and y ′ are any other positive integer solutions
to x2 − Ny2 = 1.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
However, determining the fundamental solution can be a very challenging task because
the only tool we have is to trial integer values of y and then check if 1 + Ny2 is a square
number so that x = √1 + Ny2 is an integer. So finding the fundamental solution depends
on the square-free number N and uses brute force computation.
Note that if N were one less than a square number we would trial y = 1. For example, if
N = 8, 15, 24, 35, 48, ⋯ , n2 − 1 then with y = 1 we have
Proposition (8.20). Let r = a + b√N and s = c + d√N both produce positive solutions of
Pell’s equation x2 − Ny2 = 1. Then r < s ⇔ a < c.
Proof.
See Exercises 8.3, question 13.
The next theorem tells us how to generate solutions from the least positive solution.
Theorem (8.21). Let r = a + b√N produce the least positive solution of Pell’s equation
x2 − Ny2 = 1.
n
Then this equation has all its positive integer solutions produced by r n = (a + b√N)
where n is a natural number.
Proof.
See Exercises 8.3, question 15.
Example 8.15
Solution
By trialling integer values of y = 1, 2, 3 ⋯ into x = √1 + 12y2 we obtain the solution
2
x = √1 + 12 (2) = 7, y = 2 which implies r = 7 + 2√12.
(continued...)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
2 2
r 2 = (7 + 2√12) = 49 + (2 × 7 × 2√12) + (2√12)
= 49 + 28√12 + 48 = 97 + 28√12.
Summary
In this section we have found solutions of Pell’s equation
We find the least positive solution r by trialling positive integer values for y and then stopping when
1 + Ny2 is a square number. We use this least positive solution r to generate all other positive
solutions by finding positive integer powers of r.
EXERCISES 8.3
3
Number Theory: A Historical Approach by John Watkins, page 409.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
.........................................................................................................
Supplementary Problems 8
(Brief solutions at end of book. Full gcd (a, b) = 1 then both a and b are
solutions available at <http://www.oup. co. squares.
uk/companion/NumberTheory>.) 8.3. *Prove that if any prime p > 5 can be
8.1. Let n be the product of four written as a2 + 5b2 then
consecutive integers. Show that n + 1 p ≡ 1 or 9 ( mod 20) .
is a square number. 8.4. Provide another proof that if
8.2. *(i) Prove that if gcd (x, y) = g then n ≡ 7 ( mod 8) then n ≠ x2 + y2 + z2 .
gcd (xm , ym ) = gm where m is a [The number n cannot be written as
positive integer. sum of three squares.] See
(ii) Prove that if a × b = n2 and Exercises 8.2, question 11.
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
8.20. Express the following product 8.23. Prove that a solution of Pell’s
(a2 + nb2 ) (c2 + nd2 ) as x2 + ny2 by equation x2 − (N2n − 1) y2 = 1 where
writing out the integers x and y. n is a natural number is
8.21. Prove that if each of the integers y = 1, x = Nn .
n1 , n2 , n3 , ⋯ , nk can be written as
8.24. Prove that there are infinitely many
sum of two squares then their
integer solutions of
product can also be written as a sum
of two squares. x2 − (N2 + 1) y2 = 1.
8.22. ∗ (a) Prove that there are infinitely 8.25. ***Prove that every prime p > 3
many integer solutions of satisfies p ≡ 1 or 3 (mod 8) ⇔
p = x2 + 2y2 .
x 2 − Ny 2 = z 2 (If p = 2 then x = 0, y = 1 and if
p = 3 then x = y = 1.)
for any integer N.
8.26. Prove that every prime p > 3 that
(b) Determine the fundamental
satisfies p ≡ 1 (mod 3) can be written
solution of Pell’s equation
as p = x2 + 3y2 .
x2 − 230y2 = 1. (If p = 3 then x = 0, y = 1.)
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
Brief solutions
CHAPTER 1
EXERCISES 1.1
1. 12 9. 11
3
2. 19, 10. |a|
11
3. 13, 5 ∶ 77 11. |a + b|
4. 100Hz 12. False.
5. (a) 4 (b) 9 (c) 16 (d) 2 13. (a) Any integer
6. (a) 2 (b) 12 (c) 12 (d) 91 (b) ±1, ±2
7. x = −4, y = 1 or x = 6, y = −1 17. 22 |11 × 12 but 22 11 or 22 12.
(Any example like this will do.)
8. x = −1, y = 1
EXERCISES 1.2
1. (a) q = 4, r = 3
(b) q = −84, r = 7
(c) q = −73, r = 0
EXERCISES 1.3
1. (a) 6 (b) 3 (c) 37 (d) 1 4. (You may get different answers to the
2. (You may get different answers to the following because the solutions are not
following because the solutions are not unique.)
unique.) (i) x = −2, y = 1
(a) x = −1, y = 9 (ii) x = −4, y = 2
(b) x = −47, y = 6 (iii) x = 20, y = −10
(c) x = 1, y = −6 5. x = x0 c, y = y0 c
(d) x = −91, y = 71 9. (a) a = −5, b = −10
3. (a) 6 (b) 3 (b) a = −100, b = −200
(c) 9 (d) 2 (c) a = −169, b = −338
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
370 BR IE F SOLU TI O N S
EXERCISES 1.4
SUPPLEMENTARY PROBLEMS 1
BR I E F S O LU T I O N S 371
CHAPTER 2
EXERCISES 2.1
EXERCISES 2.2
EXERCISES 2.3
EXERCISES 2.4
SUPPLEMENTARY PROBLEMS 2
372 BR IE F SOLU TI O N S
CHAPTER 3
EXERCISES 3.1
1. (a) {0, 1, 2, 3, 4}, {0, −1, −2, −3, −4}, (d) 11 (mod 5200)
and {5, 6, 7, 8, 9} (e) 5186 ( mod 5200)
(b) {0, 1, ⋯ , 8, 9} , {−1, −2, ⋯ , −9, −10}, (f) 40 ( mod 5200)
and {10, ⋯ , 18, 19} 6. 4 ( mod 5), 2 ( mod 11) and
(c) {0, 1, ⋯ , 11, 12} , {−1, ⋯ , −12, −13}, 728 ( mod 1001)
and {13, ⋯ , 24, 25} 7. (a) 61 (b) 43
2. (a) 0 ( mod 11) missing. 8. (a) true (b) false (c) false
(b) 11 ≡ 0 ( mod 11) (d) false (e) true (f) true
(c) 13 ≡ 2 ( mod 11) 9. (a) 1 (b) 1 (c) 6 (d) 6
3. (a) {0, 1, ⋯ , 5} 10. 16
(b) {0, 1, ⋯ , 10, 11}
19. (a) 50 (b) 1
(c) {0, 1, ⋯ , 15, 16}
21. 3
4. (a) 4 (b) 6 (c) 10
(d) 1000 (e) 3 (f) 20 22. (a) 1 (b) 9 (c) 9
5. (a) 3 (mod 2787)
(b) 2 (mod 2787)
(c) 12 (mod 5200)
EXERCISES 3.2
BR I E F S O LU T I O N S 373
EXERCISES 3.3
EXERCISES 3.4
374 BR IE F SOLU TI O N S
EXERCISES 3.5
SUPPLEMENTARY PROBLEMS 3
3.1. (a) T (b) F (c) F (d) T (e) T 3.4. 2, 3, 4, 6, 8, 9 and 10 ( mod 12)
3.2. (a) 3 ( mod 5) (b) 2, 11, 20 ( mod 27) 3.5. 3 × 71 × 227
(c) 2, 5, 8, 11, ⋯ , 29 ( mod 30) 3.12. 52 ≡ 1 ( mod 2)
(d) No solution
3.13. (a) 58 ( mod 60) (b) 103
3.3. (a) 5 (mod 12) (b) 13 (mod 15)
3.18. (i) 1, 3, 5 and 7 ( mod 8)
(c) 19 (mod 27) (d) No inverse
(ii) ±1 ( mod 7)
(e) 7 (mod 12) (f) 11 (mod 12)
(g) 3 (mod 13) (h) No inverse 3.19. 46 061 × 44 021
CHAPTER 4
EXERCISES 4.1
BR I E F S O LU T I O N S 375
EXERCISES 4.2
EXERCISES 4.3
EXERCISES 4.4
EXERCISES 4.5
SUPPLEMENTARY PROBLEMS 4
376 BR IE F SOLU TI O N S
CHAPTER 5
EXERCISES 5.1
EXERCISES 5.2
SUPPLEMENTARY PROBLEMS 5
5.1. (i) 40 (ii) 53 (iii) 53 5.11. (a) 20 127 098 728 296
5.2. (a) 400 (b) 4000 (b) 309 856 001 913 024
(c) 40 000 (d) 400 000 5.12. (i) 320 (iii) 40 (iv) 𝜆 |𝜙 (561)
5.3. (a) 936 (b) 1440 5.13. (i) 72 (ii) 39
(c) 576 (d) 2016 5.17. (a) 2/5 (b) 928/929 (c) 0.65
5.4. n = 5m 5.18. {1, 7, 11, 13, 17, 19, 23, 29}
5.5. 611 1
5.23. (i) (p − 1) (p2 − 1) ⋯
5.6. 2m−1 𝜙 (n) p1 p2 ⋯ pr 1
(pr − 1)
5.7. 35 ( mod 100)
5.25. (a) 10 (b) 15 (c) 24
OUP CORRECTED PROOF – FINAL, 3/9/2020, SPi
BR I E F S O LU T I O N S 377
CHAPTER 6
EXERCISES 6.1
EXERCISES 6.2
1. (a) 1 (b) 4 (c) 4 (d) 2 8. (a) 8 (b) 80 (c) 800 (d) 8000
2. (a) 10 (b) 5 (c) 5 (d) 10 13. 11
3. Only 1 has order 1. Order does not exist 14. (a) No order (b) 13
for the rest. 15. 41
4. {1, 2, 3, 4, 5, ⋯ , 15, 16} 16. 60
7. Only 1, 5, 7 and 11 have order modulo
12. The order is 1 for 1 ( mod 12) and 2
for the rest.
EXERCISES 6.3
378 BR IE F SOLU TI O N S
EXERCISES 6.4
SUPPLEMENTARY PROBLEMS 6
BR I E F S O LU T I O N S 379
CHAPTER 7
EXERCISES 7.1
EXERCISES 7.2
EXERCISES 7.3
380 BR IE F SOLU TI O N S
EXERCISES 7.4
SUPPLEMENTARY PROBLEMS 7
CHAPTER 8
EXERCISES 8.1
BR I E F S O LU T I O N S 381
EXERCISES 8.2
EXERCISES 8.3
382 BR IE F SOLU TI O N S
SUPPLEMENTARY PROBLEMS 8
Symbolic Index
Index
IN D E X 385