0% found this document useful (0 votes)
11 views42 pages

Unit 3 - Congruence (Open University)

The document is a course outline for M381 Number Theory and Mathematical Logic, focusing on congruence and its properties. It introduces key concepts such as congruence modulo n, linear congruences, and the Chinese Remainder Theorem, while also providing historical context about mathematicians like Gauss. The content includes definitions, theorems, examples, and exercises to reinforce understanding of number theory concepts.

Uploaded by

Kris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views42 pages

Unit 3 - Congruence (Open University)

The document is a course outline for M381 Number Theory and Mathematical Logic, focusing on congruence and its properties. It introduces key concepts such as congruence modulo n, linear congruences, and the Chinese Remainder Theorem, while also providing historical context about mathematicians like Gauss. The content includes definitions, theorems, examples, and exercises to reinforce understanding of number theory concepts.

Uploaded by

Kris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

l M381 Number Theory and Mathematical Logic

Mathematics and Computing


A third level course

Number Theory

Unit 3
Congruence
97 96 95 94 93 92 91 90

98 71 70 69 68 67 66 89

99 72 53 52 51 50 65 88

100 73 54 43 42 49 64 87

101 74 55 44 41 48 63 86

102 75 56 45 46 47 62 85

103 76 57 58 59 60 61 84

104 77 78 79 80 81 82 83
CONTENTS
Introduction 4
1 Properties of Congruence 6
1.1 Definition and basic properties 6
1.2 Residue classes 9
1.3 Further properties 12
2 Divisibility Tests 14
3 Linear Congruences 16
3.1 Polynomial congruences 16
3.2 Linear congruences 18
3.3 Solving linear congruences 20
4 Simultaneous Linear Congruences 22
4.1 The Chinese Remainder Theorem 22
4.2 Solving simultaneous congruences 24
Additional Exercises 27
Solutions to the Problems 30
Solutions to Additional Exercises 35
Index 43
INTRODUCTION
It is curious how often what seem to be very different branches of
mathematics become interlinked by some problem. For more than
2000 years it had been known how to construct both an equilateral triangle
and a regular pentagon inscribed in a given circle using only compass and
straightedge. But as the seventeenth century drew to its close constructions
were still not known for any other regular polygon with a prime number of
sides. The brilliant French mathematician Fermat had been discussing the Fermat will appear frequently in
n
numbers Fn = 22 + 1 (later to become known as Fermat Numbers) the remaining units of the course.
believing them all to be prime, unaware of how intricately these numbers We shall read more about him in
Unit 4.
were woven in the solution of the polygon problem. It required the genius of
the German mathematician Gauss to see how these numbers could be used
to solve the construction problem.
Carl Frederick Gauss (1777-1855)
Gauss was unquestionably one of the greatest mathematicians of all
time. His father, a labourer in Brunswick, did not want his son to
receive an education. But Carl was an infant prodigy, and his mother
encouraged him in his studies. It is known that as a child of three he
corrected an error his father made in a wages list, and by age ten he so
amazed his schoolteacher with his arithmetic prowess that the teacher
admitted there was no more he could teach the boy. The tale is reported
that one day, to keep the children occupied, the teacher asked them to
add up all the numbers from 1 to 100. Gauss handed in his slate
immediately and to the dismay of the teacher was the only one in the
class to get the correct answer. It is presumed that Gauss had discovered
for himself the formula for the sum of the first n natural numbers.
Before he reached the age of twenty Gauss had, amongst many other
achievements, conjectured the Prime Number Theorem, proved the Law
of Quadratic Reciprocity (which we shall meet in Unit 6 ) and given a
construction using compass and straightedge for a regular 17-gon to be
inscribed in a given circle. It was this last result that launched Gauss on
his career as a mathematician and it is the first result listed in a diary
he kept of all his discoveries. The diary, which did not come to light
until some forty years after his death, records brief statements of
146 results which amply display the genius of Gauss.
But it is his book ‘Disquisitiones Arithmeticae’, published when he was
24 years old, for which Gauss is best remembered. In this renowned
work Gauss laid the foundations of modern Number Theory. It was here
that he introduced and developed the language and notations of ‘the
algebra of congruence’, and used this novel approach to produce elegant
solutions to a variety of number-theoretic problems. Towards the end of
the book Gauss returned to the construction of the regular 17-gon and
generalized his earlier result to show exactly which regular N -gons can
be constructed with compass and straightedge; the construction is
possible if, and only if, N = 2r p1 p2 . . . pk , where the primes pi are
distinct Fermat numbers and r ≥ 0.
Sadly Gauss’ career as a mathematician was foreshortened as his
interest was caught by many other subjects. In particular a succession of
discoveries gained him a deserved reputation in astronomy, and indeed
for forty years from 1807 he was the director of the Göttingen
Observatory. He is also well remembered for his work on magnetism,
where a unit of magnetic intensity is the ‘gauss’, appropriately named
after him. Late in life he expressed regret that he had abandoned
mathematics, described by him as ‘the queen of the sciences, with the
theory of numbers being the queen of mathematics’. He always held
number theory in the highest esteem and, not surprisingly, his name will
feature regularly in the coming sections.

4
Diversion
Construction of the regular pentagon. AB and CD are perpendicular diagonals. L
is the mid-point of AO. Using compasses: LC = LM ; CM = CN . CN is the
required edge.

In the final section of the previous unit we introduced the idea of a


remainder sequence, in which numbers were replaced by their remainder on
dividing by some positive integer n. Observations about the behaviour of
the remainder sequence were then projected back to reveal properties of the
original number sequence. This was the underlying idea in Gauss’
congruence. He developed an ‘arithmetic of remainders’, which he then put
to work to ease computations in many areas.
In this unit we shall introduce Gauss’ notion of congruence and develop
properties of it which will be useful in problem solving throughout the
remainder of the course. Here we shall restrict its application to a variety of
problems involving remainders and, in particular, to solving linear
congruences (which offer a more general way of looking at linear
Diophantine equations). Finally, we shall prove the classical Chinese
Remainder Theorem, which is concerned with the existence of (and how to
find) solutions to a class of problems which can be modelled as a
simultaneous system of linear congruences.

5
1 PROPERTIES OF CONGRUENCE

1.1 Definition and basic properties


It has been claimed that the result that p divides 2p−1 − 1, for every odd
prime p, was known to Chinese mathematicians over 2000 years ago. But
how does one go about confirming instances of this result? If asked to show
that 216 − 1 is divisible by 17 it would be feasible to compute 216 by hand,
subtract 1, and then carefully divide by 17. But it would be impractical to
try the same line of attack to confirm that 641 divides 2640 − 1 because this
number is so huge. We shall see in this section that such divisions need not
be as frightening as they first seem; we can investigate divisibility without
having to compute the quotient involved in the division. We shall develop an
‘arithmetic of remainders’ in which everything hinges on one key definition:

Definition 1.1 Congruence modulo n


Let n be a fixed positive integer and let a and b be any integers. We If we write a ≡ b (mod n) it is to
say that a is congruent modulo n to b if the difference a − b is divisible be understood that a and b are
by n. integers and n is a positive integer,
for the statement would not make
In symbols we write a ≡ b (mod n). sense otherwise.

If a is not congruent modulo n to b we say that a is incongruent


modulo n to b and write a *≡ b (mod n).

To illustrate the congruence notation consider the case of modulus n = 11.


We have
3 ≡ 25 (mod 11) , since 3 − 25 = −22 is a multiple of 11,
and
7 ≡ −26 (mod 11) , since 7 − (−26) = 33 = 3 × 11.
On the other hand 12 is incongruent modulo 11 to 8, since 12 − 8 = 4, and 4
is not a multiple of 11.

Problem 1.1
For each of the following statements decide whether it is true or false.
(a) 3 ≡ 29 (mod 8)
(b) 3 ≡ −29 (mod 8)
(c) 63 ≡ 37 (mod 13)
(d) 37 ≡ 63 (mod 13)
(e) 63 ≡ 63 (mod 37)
(f) 63 *≡ 13 (mod 25)

Parts (c) and (d) of Problem 1.1 illustrate one apparent property of
congruence, namely that if a is congruent modulo n to b then b is congruent
modulo n to a. Part (e) illustrates the further property that any integer is
congruent modulo n to itself. These are two of a number of general
properties of congruence which highlight certain similarities with ordinary
equality, and which we shall prove in our first result.

6
Theorem 1.1 Properties of congruence
Let n be a fixed positive integer and let a, b, c and d be any integers.
Then the following properties hold.
(a) a ≡ a (mod n).
(b) If a ≡ b (mod n) then b ≡ a (mod n).
(c) If a ≡ b (mod n) and b ≡ c (mod n) then a ≡ c (mod n).
(d) If a ≡ b (mod n) and c ≡ d (mod n) then a + c ≡ b + d (mod n).
(e) If a ≡ b (mod n) and c ≡ d (mod n) then ac ≡ bd (mod n).
(f) If a ≡ b (mod n) then ar ≡ br (mod n), for any integer r ≥ 1.

Proof of Theorem 1.1


(a) a − a = 0 = 0 × n, so a ≡ a (mod n).
(b) If a ≡ b (mod n) then there exists an integer k such that a − b = kn.
Then
b − a = −(a − b) = (−k)n,
so that b ≡ a (mod n).
(c) If a ≡ b (mod n) and b ≡ c (mod n) then there exist integers s and t
such that
a − b = sn and b − c = tn.
Adding these two equations:
(a − b) + (b − c) = sn + tn.
That is,
a − c = (s + t)n,
so that a ≡ c (mod n).
(d) If a ≡ b (mod n) and c ≡ d (mod n) then there exist integers s and t
such that
a − b = sn and c − d = tn.
Adding these two equations:
(a + c) − (b + d) = sn + tn = (s + t)n,
so that
a + c ≡ b + d (mod n) .
(e) With a − b = sn and c − d = tn as in the proof of property (d),
ac = (b + sn)(d + tn) = bd + n(bt + sd + stn),
and so
ac − bd = n(bt + sd + stn),
confirming that ac ≡ bd (mod n).
(f) The case r = 1 is trivially true. Continuing by induction, suppose the
result is true for r = k, that is, suppose ak ≡ bk (mod n) whenever
a ≡ b (mod n).
Then
ak+1 = aak ≡ bbk (mod n) , by Property (e),
≡ bk+1 (mod n) .
This confirms the truth for the case r = k + 1 and completes the
induction step.

7
The following problem gives you an opportunity to prove some simple
properties of congruence working from the definition alone.

Problem 1.2
Suppose that a ≡ b (mod n) and m is an integer. Prove the following.
(a) If m > 0 and m divides n then a ≡ b (mod m).
(b) If m > 0 then ma ≡ mb (mod mn) and ma ≡ mb (mod n).
a b " n$
(c) If d > 0 is a common divisor of a, b and n then ≡ mod .
d d d
(d) gcd(a, n) = gcd(b, n).
(e) For any integer c, a + c ≡ b + c (mod n).

Before developing further ideas, let us illustrate a range of problems in


which properties of congruence can be exploited to ease computation.

Example 1.1
Show that 3737 + 2 is divisible by 13.
We start by looking for numbers to which 3737 is congruent modulo 13. Now
as 37 ≡ −2 (mod 13), Theorem 1.1(f) tells us that
3737 ≡ (−2)37 ≡ (−1) × 237 (mod 13) .
Now
24 = 16 ≡ 3 (mod 13) ,
and so
3737 ≡ (−1) × (24 )9 × 2 ≡ (−1) × 39 × 2 (mod 13) .
But
33 = 27 ≡ 1 (mod 13) ,
so
3737 ≡ 33 × 33 × 33 × (−2) ≡ −2 (mod 13) .
Finally, Theorem 1.1(d) allows us to conclude that
3737 + 2 ≡ (−2) + 2 ≡ 0 (mod 13) ,
which amounts to saying that 3737 + 2 is divisible by 13. "

In the final step of Example 1.1 we inferred from a statement of the form
a ≡ 0 (mod n), that n divides a. This is an immediate consequence of the
definition of congruence. Indeed we have a characterization of congruence
modulo n in terms of the remainders on dividing by n, as given by the
following.

Theorem 1.2 Congruent integers have the same remainders


a ≡ b (mod n) if, and only if, the integers a and b have the same
remainder when divided by n.

Proof of Theorem 1.2


Suppose first that a and b have the same remainder when divided by n, say
a = q1 n + r and b = q2 n + r, where 0 ≤ r < n.
Then a − b = (q1 − q2 )n, showing that a ≡ b (mod n).

8
Conversely, suppose that a ≡ b (mod n), so that a − b = kn, for some integer
k. Let b have remainder r when divided by n, so that b = nq + r for some
integer q. Then,
a = b + kn = nq + r + kn = (q + k)n + r,
shows that a has the same remainder, r, as does b.

1.2 Residue classes


One outcome of Theorem 1.2 is that every integer is congruent modulo n to
exactly one of the integers 0, 1, 2, . . . , n − 1, namely, whichever one of these
is its remainder on dividing by n. This set of n integers is called the set of
least positive residues modulo n. (Strictly speaking, since 0 is not a positive
integer, it ought to be called the set of least non-negative residues, but this
misnomer is firmly entrenched in the literature.)
Furthermore we can split up Z into non-overlapping sets called residue
(or congruence) classes, where two integers belong to the same class if, and
only if, they are congruent modulo n. For example, for the case n = 4 the
residue classes are:
{. . . , −8, −4, 0, 4, 8, . . .}
{. . . , −7, −3, 1, 5, 9, . . .}
{. . . , −6, −2, 2, 6, 10, . . .}
{. . . , −5, −1, 3, 7, 11, . . .}
A set obtained by selecting one member from each of these residue classes,
for example {0, 1, 2, 3} or {8, −3, 22, −9}, is called a complete set of residues
modulo 4. In general, a set {a1 , a2 , a3 , . . . , an } of n integers is a complete set
of residues modulo n provided no two of them are congruent modulo n. By
virtue of Theorem 1.2 this will mean that the integers {a1 , a2 , a3 , . . . , an } are
congruent modulo n, in some order, to {0, 1, 2, . . . , n − 1}.
In choosing a complete set of residues modulo n, our most frequent selection
will be the set of least positive residues, {0, 1, 2, . . . , n − 1}. However we
shall have occasion to use the set of least absolute residues obtained by
choosing, from each residue class, one with least modulus. To be precise,
from each residue class modulo n we choose the unique member x which lies
in the range − 21 n < x ≤ 12 n. For example, the set of least absolute residues
for n = 4 is {−1, 0, 1, 2} whilst for n = 7 it is {−3, −2, −1, 0, 1, 2, 3}.

Problem 1.3
Write down the set of least positive residues modulo n, and the set of least
absolute residues modulo n, for (a) n = 10, and (b) n = 11.

Problem 1.4
Determine whether or not each of the following sets is a complete set of
residues modulo 11.
(a) {6, 2, −3, 22, 23, −7, 7, 9, 43, −8, 16};
(b) {02 , 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 , 102 };
(c) {0, 1, 2, 22, 23 , 24 , 25 , 26 , 27 , 28 , 29 }.

Properties (d) and (e) of Theorem 1.1 are of great importance. In essence
they say that the residue class to which a sum a + c, or a product ac, belongs
does not depend so much on the individual numbers a and c but rather on
the residue classes to which they belong. To qualify this remark, let us
denote by [r] the residue class modulo n to which the integer r belongs. So
[r] = {. . . , r − 2n, r − n, r, r + n, r + 2n, . . .}.

9
This will mean that residue classes are denoted in many different ways; for
example, taking n = 5, [−1] = [4] = [19] since −1 ≡ 4 ≡ 19 (mod 5). In this
notation properties (d) and (e) can be restated as follows.
(d) If [a] = [b] and [c] = [d] then [a + c] = [b + d].
(e) If [a] = [b] and [c] = [d] then [ac] = [bd].
These two facts amount to saying that the operations defined on the set of
residue classes modulo n by
[a] + [c] = [a + c] and [a] × [c] = [ac]
are unambiguous. Whatever numbers are chosen to represent the two
residue classes, the sum of the numbers will always belong to the same class,
as will the product of the numbers.
Let
Zn = {[0], [1], [2], . . . , [n − 1]}
be the set of all residue classes modulo n. Together with the operations of
addition and multiplication defined above we have an arithmetic on Zn . For
example, taking n = 4 we have the tables
+ [0] [1] [2] [3] × [0] [1] [2] [3]
[0] [0] [1] [2] [3] [0] [0] [0] [0] [0]
[1] [1] [2] [3] [0] [1] [0] [1] [2] [3]
[2] [2] [3] [0] [1] [2] [0] [2] [0] [2]
[3] [3] [0] [1] [2] [3] [0] [3] [2] [1]
where, for example, [3] × [2] = [2] is obtained from the definition
[3] × [2] = [3 × 2] = [6]
and the fact that [6] = [2] since 6 ≡ 2 (mod 4).

Problem 1.5
Working in Z10 , determine [6] + [8] and [6] × [8] and find all [b] such that
[6] × [b] = [8].
Repeat the above, this time working in Z11 .

Diversion
1×8 + 1 = 9
12 × 8 + 2 = 98
123 × 8 + 3 = 987
1234 × 8 + 4 = 9876
12345 × 8 + 5 = 98765
123456 × 8 + 6 = 987654
1234567 × 8 + 7 = 9876543
12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321

A problem in congruence modulo n is equivalent to a problem in Zn with its


arithmetic as illustrated in Problem 1.5 above. In practice, however, we shall
abandon much of this formalism. What we shall do is select a complete set
of residues, (usually the set of least positive residues), and work with these
numbers, dropping the square brackets. When any sum or product is
calculated we replace the answer by the chosen residue to which it is
congruent. Here are a couple of illustrations of the way in which congruence
is used.

10
Example 1.2
Show that 13 + 23 + 33 + · · · + 603 is divisible by 5.
In terms of congruence we are asked to show that 13 + 23 + 33 + · · · + 603 is
congruent modulo 5 to 0. Now each of the terms r3 is congruent modulo 5
to one of 0, 1, 2, 3 or 4, and so one line of attack would be to evaluate the
least positive residue modulo 5 of each of these cubes and add up. However,
a considerable short-cut is provided by Theorem 1.1(f), which tells us that if
two numbers are congruent modulo 5 then their cubes are also congruent
modulo 5. So, since 1 ≡ 6 ≡ 11 ≡ · · · ≡ 56 (mod 5), we have
13 ≡ 63 ≡ 113 ≡ · · · ≡ 563 (mod 5) .
Similarly
23 ≡ 73 ≡ 123 ≡ · · · ≡ 573 (mod 5) ;
33 ≡ 83 ≡ 133 ≡ · · · ≡ 583 (mod 5) ;
43 ≡ 93 ≡ 143 ≡ · · · ≡ 593 (mod 5) ;
53 ≡ 103 ≡ 153 ≡ · · · ≡ 603 (mod 5) .
Therefore,
13 + 23 + 33 + · · · + 603 ≡ 12 × (13 + 23 + 33 + 43 + 53 ) (mod 5) . There are simpler ways of solving
Example 1.2. For instance, you
Now, may be familiar with the formula
&
n # %2
23 ≡ 3, 33 = 27 ≡ 2, 43 = 64 ≡ 4 and 53 ≡ 03 ≡ 0 (mod 5) , r3 =
n(n + 1)
2
and so r=1
in which case, putting n = 60, the
13 + 23 + 33 + · · · + 603 ≡ 12 × (1 + 3 + 2 + 4 + 0) = 120 ≡ 0 (mod 5) , result drops out. Our solution here
intentionally illustrates the use of
as claimed. " the properties of congruence.

Example 1.3
Show that there do not exist integers x and y such that x2 + y 2 = 999.
At first glance it might be difficult to see what this question has to do with
congruence. In fact, it is a particular case of a general result concerning the
possible values that a sum of two squares can take modulo 4.
Any integer x is congruent modulo 4 to one of the integers 0, 1, 2 or 3.
Theorem 1.1(f) tells us that x2 is therefore congruent modulo 4 to one of the
numbers 02 , 12 , 22 or 32 . That is, x2 is congruent modulo 4 to either 0 or 1
(since 22 ≡ 0 (mod 4) and 32 ≡ 1 (mod 4)). Similarly, for any integer y, y 2
is congruent modulo 4 to either 0 or 1. Theorem 1.1(d) now gives
x2 + y 2 ≡ 0, 1 or 2 (mod 4)
(as 0, 1 and 2 are the possible results of adding either 0 or 1 to either 0 or 1).
This argument tells us that any integer which is congruent modulo 4 to 3
cannot be written as the sum of two squares. Now 999 ≡ 3 (mod 4) is such
an integer, and so the equation
x2 + y 2 = 999
cannot have a solution in integers. "

And now some for you to try.

Problem 1.6
What is the remainder when 1! + 2! + 3! + · · · + 1000! is divided by 7?

Problem 1.7
Let a be an integer which is not divisible by either 2 or 3. Prove that a2 − 1
is divisible by 24. Hint : Show a2 ≡ 1 (mod 24).

11
1.3 Further properties
There is a property of congruence which, although it is no more than a
re-expression of an established divisibility property, will be used so often
that it merits the status of a theorem.

Theorem 1.3
If a ≡ b (mod m) and a ≡ b (mod n), then
a ≡ b (mod lcm(m, n)) .

Proof of Theorem 1.3


From the definition of congruence there exist integers r and s such that
a − b = rm and a − b = sn.
Let d = gcd(m, n), so that
m = dm# and n = dn# , where gcd(m# , n# ) = 1. Theorem 4.5 of Unit 1 establishes
that gcd(m" , n" ) = 1.
Substituting for m and n in the equation rm = sn gives
rdm# = sdn# ; that is rm# = sn# .
We infer from this that n# divides rm# , whereupon Euclid’s Lemma gives us
that n# divides r. So putting r = kn# we have
"n$ " mn $
a − b = rm = kmn# = km =k = k lcm(m, n). See Theorem 4.8 of Unit 1.
d d
That is, a ≡ b (mod lcm(m, n)), as claimed.

One particular case of Theorem 1.3 is well worth highlighting. We shall


frequently want to apply this result when m and n are relatively prime, in
which case lcm(m, n) = mn.

Corollary to Theorem 1.3


If a ≡ b (mod m) and a ≡ b (mod n) , where gcd(m, n) = 1, then
a ≡ b (mod mn).

Notice how much simpler Problem 1.7 would have been with the benefit of
Theorem 1.3. To show that a2 ≡ 1 (mod 24) it is sufficient to show that
a2 ≡ 1 (mod 8) and a2 ≡ 1 (mod 3). Both these separate parts are quickly
confirmed from congruence ideas:
(1) a odd implies a ≡ 1, 3, 5 or 7 (mod 8), and squaring,
a2 ≡ 1 (mod 8) in all cases;
(2) a not divisible by 3 implies a ≡ 1 or 2 (mod 3), and squaring,
a2 ≡ 1 (mod 3) in each case.

We have seen that if a ≡ b (mod n) then ca ≡ cb (mod n), for any integer c.
What about the converse of this result? If ca ≡ cb (mod n) can we
legitimately cancel the c’s to recover a ≡ b (mod n)? In fact we cannot, as
this simple counter-example shows:
2 ≡ 8 (mod 6) but 1 *≡ 4 (mod 6) .
Here, cancellation of the common divisor 2 has produced a contradiction.

12
Common divisors on two sides of a congruence can always be cancelled, but
in doing so the modulus has to be adjusted according to the following rule.

Theorem 1.4 Cancellation rule


" n$
If ca ≡ cb (mod n) then a ≡ b mod , where d = gcd(c, n).
d

Proof of Theorem 1.4


From ca ≡ cb (mod n) we know that there exists an integer k such that
ca − cb = kn. Now gcd(c, n) = d, and so there exist relatively prime integers
r and s such that c = dr and n = ds. Therefore, substituting for c and n in Theorem 4.5 of Unit 1 established
the equation ca − cb = kn gives that r and s are relatively prime.

dra − drb = kds,


which, after cancelling the common d, gives
r(a − b) = ks.
From this s divides r(a − b) and, as gcd(r, s) = 1, Euclid’s Lemma confirms
n
that s divides a − b. Consequently a ≡ b (mod s), where s = .
d
One special case of Theorem 1.4 is worth noting. When gcd(c, n) = 1 the
common divisor c can be cancelled without the need to adjust the modulus
and is stated formally as follows.

Corollory to the cancellation rule


If ca ≡ cb (mod n), where gcd(c, n) = 1, then a ≡ b (mod n).

In fact the two congruences in Theorem 1.4 are ‘equivalent’ because the
reverse implication also holds. That is,
" n$
if a ≡ b mod then ca ≡ cb (mod n) , where d = gcd(c, n).
d
" n$
To justify this remark, suppose that a ≡ b mod . Then there is an
d
integer k such that
n
a−b=k .
d
Multiplying by c:
kc
ca − cb = n,
d
c
so that ca ≡ cb (mod n), since is an integer.
d
We shall make use of the symbol ↔ to indicate that two congruences are
equivalent. For example, after cancellation of the common divisor 6 in the
following,
12x ≡ 18 (mod 27) ↔ 2x ≡ 3 (mod 9) .

Problem 1.8
Use an appropriate cancellation to simplify each of the following
congruences:
(a) 6x ≡ 18 (mod 30);
(b) 20x ≡ 30 (mod 45);
(c) 52x ≡ 39 (mod 60).

13
Before we leave this area of congruence properties there is one final result
which merits our attention. Euclid’s Lemma for the case of a prime divisor p
showed that if p divides ab, then either p divides a or p divides b. When this
is expressed in congruence notation we have the result which follows. We
shall have numerous occasions to refer to this result so, to ease identification
of the reference, we shall continue to call it Euclid’s Lemma for prime
divisors.

Theorem 1.5 Euclid’s Lemma for prime divisors


If ab ≡ 0 (mod p) then a ≡ 0 (mod p) or b ≡ 0 (mod p).

In problem 1.8 we have made a start at solving congruence problems. We


shall return to this in Section 3; but first we take a short detour.

2 DIVISIBILITY TESTS
Given any integer written in our familiar decimal representation, we can tell
at a glance whether or not it is divisible by 2 or 5. To test divisibility by 5,
for example, we simply look to see whether or not the units digit is 0 or 5.
Though not quite so immediate, there are also fairly simple tests for
divisibility by 3, 4, 8, 9 and 11. All these divisibility tests can be derived
from congruence ideas.
Historically, the most significant divisibility test is that for division by 9.
A positive integer is divisible by 9 if, and only if, the sum of its digits is
divisible by 9.
In fact this is a special case of a stronger result which we shall prove shortly.
A positive integer is congruent modulo 9 to the sum of its digits.
For example, if N = 974 064 then
N ≡ 9 + 7 + 4 + 0 + 6 + 4 = 30 ≡ 3 (mod 9) .
This fact led to a method of checking calculations, known as ‘casting out
nines’ which, over the years, has been much used by book-keepers. The
method amounts to reworking the calculations in the residue class
arithmetic Z9 . As an illustration, consider the multiplication shown in
Figure 2.1. On the left the multiplication is carried out fully, whilst on the
right the same calculation is carried out modulo 9.

1489 1 + 4 + 8 + 9 = 22 ≡ 4 (mod 9)
× 753 7 + 5 + 3 = 15 ≡ 6 (mod 9)
1042300 4 × 6 = 24 ≡ 6 (mod 9)
74450
4467
1121217 Check: 1 + 1 + 2 + 1 + 2 + 1 + 7 = 15 ≡ 6 (mod 9)

Figure 2.1 Casting out nines

The fact that the two answers agree modulo 9 is far from being conclusive
proof that the calculation is correct. However, there is a good chance that a
mistake in carrying out the calculation would have shown up during this
check.

14
We shall prove the results giving divisibility tests for 9 and 11 together in
the following theorem.

Theorem 2.1 Divisibility by 9 and 11


Let the integer N be written in decimal notation as The well-known test for division
N = am am−1 . . . a2 a1 a0 so that the digits satisfy 0 ≤ ai ≤ 9 with by 3: A positive integer is divisible
am *= 0. Then: by 3 if, and only if, the sum of its
digits is divisible by 3, follows
(a) N ≡ a0 + a1 + a2 + a3 + · · · + am (mod 9); immediately from part (a).
(b) N ≡ a0 − a1 + a2 − a3 + · · · + (−1)m am (mod 11).

Proof of Theorem 2.1


The key is to write out the number N in terms of powers of 10, namely
N = a0 + 10a1 + 102 a2 + 103 a3 + · · · + 10m am .
(a) Since 10 ≡ 1 (mod 9), it follows from Theorem 1.1(f) that
10r ≡ 1 (mod 9) for all integers r ≥ 1. Thus, from properties (d) and (e)
of Theorem 1.1,
N ≡ a0 + 1a1 + 1a2 + 1a3 + · · · + 1am (mod 9)
≡ a0 + a1 + a2 + a3 + · · · + am (mod 9) .
(b) Similarly, since 10 ≡ −1 (mod 11), 10r ≡ (−1)r (mod 11) for all
integers r and
N ≡ a0 + (−1)a1 + (−1)2 a2 + · · · + (−1)m am (mod 11)
≡ a0 − a1 + a2 − a3 + · · · + (−1)m am (mod 11) .

In the congruences of parts (a) and (b) of Theorem 2.1, and in their proofs,
we have unnecessarily used the digits of N in reverse order, starting at the
units digit a0 . It will be helpful to use formula (b) in this way, starting at
the positive units digit and then alternating the signs. But in using (a) we
shall often, as we did in Figure 2.1 above, add the digits in their naturally
occurring order.

Diversion
987654321 × 9 = 8888888889
987654321 × 18 = 17777777778
987654321 × 27 = 26666666667
987654321 × 36 = 35555555556
987654321 × 45 = 44444444445
987654321 × 54 = 53333333334
987654321 × 63 = 62222222223
987654321 × 72 = 71111111112
987654321 × 81 = 80000000001

Problem 2.1
Let N = 9723 and M = 18 056.
(a) Determine the remainders when each of the numbers N , M , N + M and
N − M are divided by (i) 9 and (ii) 11.
(b) Determine the missing digit (?) in the product
N × M = 9723 × 18 056 = 175 (?)58 488
without using a calculator.

15
Problem 2.2
An integer N has an even number of digits. A second integer M is formed
by moving the last digit of N to the front. (For example, if N = 588 471
the 1 is moved to the front giving M = 158 847.) Show that 9 divides
N − M , 11 divides N + M and 99 divides N 2 − M 2 .

There are numerous variations on a trick which capitalizes on the connection


between a number and the sum of its digits. Ask a person to give any 3-digit
number (which is not palindromic). Without knowing what the number is, a
prediction is made that application of the following sequence of operations
on the number will produce the answer 1089.
Write down the number and the number formed by reversing the order of its
digits. Then subtract the smaller of these numbers from the larger. Finally It may happen that the first
add to this the number formed by reversing its digits. subtraction produces a 2-digit
number. This is treated as a 3-digit
For example, if the chosen number is 638 then this is subtracted from 836 number with leading 0 for the
giving 198. Adding 198 to 891 gives 1089. The work of this section should purposes of reversing its digits. For
enable you to explain why this is so. example, 99 would reverse to 990.

3 LINEAR CONGRUENCES

3.1 Polynomial congruences


Having studied basic properties of congruence, the next step is to look at the
problem of solving congruences involving unknowns, such as
3x ≡ 7 (mod 12) or x5 − x3 ≡ 0 (mod 8). The first of these examples
happens to have no solutions, for there is no integer x for which
3x ≡ 7 (mod 12). On the other hand every integer x satisfies
x5 − x3 ≡ 0 (mod 8) — try one!
By an integral polynomial we mean a polynomial
P (x) = cm xm + cm−1 xm−1 + · · · + c1 x + c0
in which the coefficients c0 , c1 , . . . , cm and the variable x are integers. If
P (x) is an integral polynomial then the congruence P (x) ≡ 0 (mod n) is a
polynomial congruence. Our present interest is in solving polynomial
congruences and we shall show straightaway that if an integer a is a solution
of the congruence, that is, P (a) ≡ 0 (mod n), then so too is every integer in
the residue class modulo n of a.

Theorem 3.1
Let P (x) be an integral polynomial. If a ≡ b (mod n) then
P (a) ≡ P (b) (mod n). In particular, a is a solution of the polynomial
congruence P (x) ≡ 0 (mod n) if, and only if, b is a solution.

16
Proof of Theorem 3.1
Let P (x) = cm xm + cm−1 xm−1 + · · · + c1 x + c0 . Since a ≡ b (mod n),
properties (e) and (f) of Theorem 1.1 tell us that cr ar ≡ cr br (mod n), for
each integer r ≥ 1. Property (d) of Theorem 1.1 then gives
P (a) = cm am + cm−1 am−1 + · · · + c1 a + c0
≡ cm bm + cm−1 bm−1 + · · · + c1 b + c0 ≡ P (b) (mod n) .
In particular, P (a) ≡ 0 (mod n) if, and only if, P (b) ≡ 0 (mod n). That is, a
is a solution of the congruence P (x) ≡ 0 (mod n) if, and only if, b is a
solution.

As a consequence of Theorem 3.1, it is apparent that the problem of solving


the congruence P (x) ≡ 0 (mod n) is really a problem in the residue class
arithmetic Zn ; if an integer is a solution then so too is every integer in its
residue class. So the task is to find which residue classes solve the
congruence. Two congruent integers which satisfy a polynomial congruence
will be thought of as being the same solution.

Definition 3.1 Number of solutions of a polynomial congruence.


Let S = {b1 , b2 , . . . , bn } be a complete set of residues modulo n. The
number of solutions of the congruence P (x) ≡ 0 (mod n) is the number
of integers b ∈ S for which P (b) ≡ 0 (mod n).

Here is an example.

Example 3.1
Solve the polynomial congruence x2 − x ≡ 0 (mod 6).
There are six residue classes modulo 6 and each may be a solution of the
congruence. We choose the least positive residues, 0, 1, 2, 3, 4 and 5 and
test each one in turn.
02 − 0 ≡ 0 (mod 6)
12 − 1 ≡ 0 (mod 6)
22 − 2 ≡ 2 (mod 6)
32 − 3 ≡ 0 (mod 6)
42 − 4 ≡ 0 (mod 6)
52 − 5 ≡ 2 (mod 6)
We see that 0, 1, 3 and 4 are solutions of the congruence and therefore so
too is any integer congruent modulo 6 to one of 0, 1, 3 or 4. On the other
hand any integer which is congruent modulo 6 to either 2 or 5 does not
satisfy the congruence. The congruence has four solutions:
x ≡ 0, 1, 3, 4 (mod 6) . "

Problem 3.1
Solve the following polynomial congruences.
(a) P1 (x) = x2 + 3x + 4 ≡ 0 (mod 7)
(b) P2 (x) = x4 − 1 ≡ 0 (mod 5)

17
3.2 Linear congruences
We have quickly found an algorithmic method for solving polynomial This method of solving a problem
congruences, namely, substitute for x, in turn, each value from any complete by checking every possible
set of residues and record the resulting zeros. This is all well and good when candidate is called solution by
exhaustion.
the modulus in question is reasonably small and the degree of the
polynomial is not too large. For more awkward polynomials the amount of
computation involved in this sledgehammer attack quickly renders it
impractical, and we must look around for something more subtle. In Unit 4
we shall return to the problem of solving general polynomial congruences.
There we shall discover ways of simplifying polynomial congruences and we
shall be able to predict how many solutions a polynomial congruence will
have. In Unit 6 we shall be very much concerned with quadratic
congruences and their solutions. For the remainder of this unit we shall
confine our attention to the linear congruence
ax ≡ b (mod n) .
This, the simplest of all polynomial congruences, crops up naturally in a
variety of situations in number theory.
Suppose that x0 is an integer such that ax0 ≡ b (mod n). This means that
n divides ax0 − b or, put another way, there exists an integer y0 such that
ax0 − b = ny0 .
Rearranging, this equation tells us that x = x0 , y = y0 is a solution of the
linear Diophantine equation ax − ny = b. On the other hand if x = x0 ,
y = y0 is any solution of ax − ny = b then it is certainly the case that
ax0 ≡ b (mod n). Thus the problem of finding all integers satisfying the
linear congruence ax ≡ b (mod n) is precisely the same problem as finding
all x-values in solutions of the linear Diophantine equation ax − ny = b. As
we have already solved the latter problem in Theorem 5.1 of Unit 1, our
principal result on linear congruences is little more than a re-expression of
that earlier theorem.

Theorem 3.2 Solution of linear congruences


Consider the linear congruence ax ≡ b (mod n).
(a) The congruence has solutions if, and only if, gcd(a, n) divides b.
(b) If gcd(a, n) = 1, the congruence has a unique solution.
(c) If gcd(a, n) = d and d divides b, then the congruence has d
n
solutions which are given by the unique solution modulo of the
d
congruence
a b $ n%
x≡ mod .
d d d

Proof of Theorem 3.2


(a) The linear Diophantine equation ax − ny = b has solutions if and only if
gcd(a, n) divides b. From the remarks preceding the theorem, it follows
that the congruence ax ≡ b (mod n) has solutions if, and only if,
gcd(a, n) divides b.
(b) Suppose that gcd(a, n) = 1. Theorem 5.1 of Unit 1 tells us that if
x = x0 , y = y0 is one solution of ax − ny = b, then the general solution
is
x = x0 + nk, y = y0 + ak, k ∈ Z.
But for all integers k
x0 + nk ≡ x0 (mod n)
and so x ≡ x0 (mod n) is the only solution of ax ≡ b (mod n).

18
(c) If gcd(a, n) = d and d divides b then
a b $ n%
ax ≡ b (mod n) ↔ x ≡ mod .
d d d
$a n%
But gcd , = 1, and so the right-hand congruence has a unique
d d
n
solution modulo , say
d
$ n%
x ≡ x1 mod .
d
Hence the integers x which satisfy ax ≡ b (mod n) are precisely those of
n
the form x = x1 + k , for some integer k.
d
Consider the set of d integers
" n n n#
x1 , x1 + , x1 + 2 , . . . , x1 + (d − 1) .
d d d
Certainly no two of these integers are congruent modulo n because they
are distinct and no two differ by as much as n. We claim further that,
n
for any integer k, x1 + k is congruent modulo n to one of them. To see
d
why that is so, write k = dq + r, where 0 ≤ r < d, as given by the
Division Algorithm. Then
n n n
x1 + k = x1 + (dq + r) = x1 + nq + r
d d d
n
≡ x1 + r (mod n) .
d
So these are the d solutions of ax ≡ b (mod n).

To illustrate part (c) and its proof, consider the congruence


12x ≡ 15 (mod 21) .
Since gcd(12, 21) = 3, and 3 divides 15, the congruence has three solutions
modulo 21.
Cancellation of the common 3 reduces the congruence to
4x ≡ 5 (mod 7)
which has a unique solution modulo 7, since gcd(4, 7) = 1. That solution is
x ≡ 3 (mod 7)
as can be seen from 4 × 3 ≡ 5 (mod 7). The argument in the proof of
part (c) then supplies the three solutions to modulus 21 as
x ≡ 3 (mod 21) , x ≡ 3 + 7 ≡ 10 (mod 21) and x ≡ 3 + 2 × 7 ≡ 17 (mod 21) .

Problem 3.2
How many solutions does each of the following linear congruences have?
(a) 5x ≡ 13 (mod 10)
(b) 5x ≡ 10 (mod 13)
(c) 10x ≡ 5 (mod 30)
(d) 27x ≡ 318 (mod 24)

Diversion
Some squares containing the nine non-zero digits. There are 83 such squares in all.
118262 = 139854276 255722 = 653927184
125432 = 157326849 159632 = 254817369
242372 = 587432169 290342 = 842973156
244412 = 597362481 303842 = 923187456

19
3.3 Solving linear congruences
It is nice to have a theoretical result telling us that solutions exist but it is
more important to be able to find those solutions.

Example 3.2
Solve the linear congruence 30x ≡ 15 (mod 33).
As gcd(30, 33) = 3 and 3 divides 15 Theorem 3.2 guarantees that the
congruence has three solutions modulo 33. Failing all else we know that we
could find these solutions by substituting for x each of the values
0, 1, 2, 3, . . . , 32 and recording which are solutions. But this last resort can
usually be avoided, and can here, as we shall illustrate.
For a start we can use the cancellation laws to reduce the modulus. By the
cancellation rule, Theorem 1.4, the common divisor 3 in both coefficients
and modulus can be cancelled to give the equivalent congruence The congruences are ‘equivalent’ in
the sense that an integer x is a
10x ≡ 5 (mod 11) . solution of one congruence if, and
only if, it is a solution of the other.
As gcd(10, 11) = 1 we know, by Theorem 3.2(b), that this congruence has a
unique solution modulo 11.
Next we can cancel further. By the cancellation rule the common divisor 5
in the coefficients can be cancelled, this time the modulus remaining
unchanged:
2x ≡ 1 (mod 11) .
There are a number of ways of determining the unique solution modulo 11
from here. For example, we could replace the number 1 on the right-hand
side of the congruence by 12, since 1 ≡ 12 (mod 11):
2x ≡ 12 (mod 11) .
Finally cancellation of the common divisor 2 of the coefficients yields the
solution:
x ≡ 6 (mod 11) .
Alternatively we could have multiplied through the congruence
2x ≡ 1 (mod 11) by 6, obtaining
12x ≡ 6 (mod 11) ,
whereupon replacement of the coefficient 12 by the congruent number 1
yields the same solution
x ≡ 6 (mod 11) .
We noted that the original congruence had three solutions modulo 33 and
we have ended with a unique solution modulo 11. There is no contradiction
here, for in the set of least positive residues modulo 33 there are three
numbers, namely 6, 17 and 28, which are congruent to 6 modulo 11.
Consequently the unique solution x ≡ 6 (mod 11) is equivalent to the three
solutions
x ≡ 6, 17, 28 (mod 33) ,
for both determine the same set of integers, namely,
{. . . , −38, −27, −16, −5, 6, 17, 28, 39, 50, . . .}.
So either form can be taken as the answer here. Normally, except when the
context of the problem demands otherwise, we shall always give the
solution(s) in terms of the original modulus. "

20
Linear congruences, like the one we have just tackled, can all be solved using
the following strategy.

Strategy: to solve the linear congruence ax ≡ b (mod n)


1 Check that gcd(a, n) divides b. If it does not the congruence has
no solutions. If it does:
2 Cancel any common divisors of all three of a, b and n. The
resulting congruence has a unique solution modulo the new
modulus.
The resulting coefficients (originally a and b) can then be changed
by applying the remaining steps in any order, any number of times,
with the goal of reaching a congruence in which the coefficient
of x is 1.
3 Cancel any common divisor of the coefficients.
4 Replace either coefficient by any congruent number.
5 Multiply through the congruence by any number which is
relatively prime to the modulus.

Step 5 needs a little clarification. To illustrate why the multiplier has to be


relatively prime to the modulus, consider the congruence
7x ≡ 1 (mod 40) .
If we multiply through by 6 we get
42x ≡ 6 (mod 40) ,
and replacing 42 by the congruent number 2
2x ≡ 6 (mod 40) .
Plainly x ≡ 3 (mod 40) is a solution of this congruence because
2 × 3 ≡ 6 (mod 40), but it is not a solution of the original congruence
because 7 × 3 = 21 %≡ 1 (mod 40). So somewhere along the line an
extraneous solution has been introduced.
The problem arose when we multiplied through the congruence by 6,
because gcd(6, 40) > 1. From ax ≡ b (mod n) it is certainly true that
cax ≡ cb (mod n). But, according to Theorem 1.4, the cancellation rule, we
can only reverse the argument and draw the conclusion ax ≡ b (mod n) from
cax ≡ cb (mod n) when gcd(c, n) = 1. A solution of cax ≡ cb (mod n) is not
necessarily a solution of ax ≡ b (mod n) unless gcd(a, n) = 1. Hence the
relatively prime condition of Step 5 must hold before we multiply through a
congruence.
The way to become proficient at solving linear congruences is through plenty
of practice at applying the above strategy. We shall do one more example
before inviting you to try your hand.

Example 3.3
Solve 9x ≡ 15 (mod 26).
As gcd(9, 26) = 1, Step 1 tells us that 9x ≡ 15 (mod 26) has a unique
solution modulo 26, and Step 2 is not applicable.
9x ≡ 15 (mod 26) ↔ 3x ≡ 5 (mod 26) , by Step 3,
↔ 27x ≡ 45 (mod 26) , by Step 5, multiplying by 9,
↔ x ≡ 45 (mod 26) , by Step 4,
↔ x ≡ 19 (mod 26) , by Step 4. "

21
The steps that we followed in this example are certainly not unique. There
are many ways of solving the congruence, but, of course, all must lead to the
same conclusion.

Problem 3.3
Solve the following linear congruences.
(a) 28x ≡ 49 (mod 53)
(b) 34x ≡ 19 (mod 52)
(c) 137x ≡ 96 (mod 19)
(d) 51x ≡ 8 (mod 53)
(e) 18x ≡ 39 (mod 69)

4 SIMULTANEOUS LINEAR
CONGRUENCES

4.1 The Chinese Remainder Theorem


In the first century AD the Chinese mathematician Sun-Tsu posed the
following problem.

Example 4.1
Find a number which leaves remainders 2, 3 and 2 when divided by 3, 5 and
7 respectively.
In congruence notation the problem is asking for a simultaneous solution of By ‘simultaneous solution’ we
the system mean an x which satisfies all the
congruences.
x ≡ 2 (mod 3) ; x ≡ 3 (mod 5) ; x ≡ 2 (mod 7) .
We can solve this problem as follows. To satisfy the first congruence x must
be of the form 3r + 2. To satisfy the second congruence as well requires
3r + 2 ≡ 3 (mod 5) , i.e. 3r ≡ 1 (mod 5) .
This has the unique solution r ≡ 2 (mod 5), i.e. r = 5s + 2 for some integer
s. Therefore
x = 3r + 2 = 3(5s + 2) + 2 = 15s + 8.
This number has to satisfy the third and final congruence.
15s + 8 ≡ 2 (mod 7) ↔ 1s + 1 ≡ 2 (mod 7)
This has the unique solution s ≡ 1 (mod 7). So s = 7t + 1 for some integer t
and, substituting in the expression for x,
x = 15(7t + 1) + 8 = 105t + 23.
Any integer x of this form satisfies all three congruences. The least positive
solution is 23 (corresponding to t = 0) and the complete solution is
x ≡ 23 (mod 105). "

Consider now a general system of simultaneous linear congruences to be


solved simultaneously, that is, a system
a1 x ≡ b1 (mod n1 ) ; a2 x ≡ b2 (mod n2 ) ; . . . ; ar x ≡ br (mod nr ) .

22
For an integer x to be a simultaneous solution of the system it must be a
solution of each of the r individual congruences, and consequently a
necessary condition for a solution is that
gcd(ai , ni ) divides bi , for each i = 1, 2, . . . , r.
Assuming that this condition holds, a first step in solving the simultaneous
system is to solve each individual congruence, finding its unique solution to
the appropriate modulus. From then on we can confine attention to solving
simultaneous systems of the form
x ≡ b1 (mod n1 ) ; x ≡ b2 (mod n2 ) ; ... ; x ≡ br (mod nr )
as in Sun Tsu’s problem.
The fact that each congruence is solvable is not sufficient on its own for the
simultaneous system to have a solution. For example, consider the following
system.
x ≡ 1 (mod 2) ; x ≡ 2 (mod 4)
No even integer satisfies the first congruence and no odd integer satisfies the
second; hence the simultaneous system has no solutions. Inconsistencies,
such as the one illustrated here, can arise when two linear congruences have
moduli which are not relatively prime. However, if we restrict ourselves to
systems in which every pair of moduli are relatively prime, it turns out that
simultaneous solutions always exist. In honour of their early contributions in
this area, this result is known as the Chinese Remainder Theorem.

Theorem 4.1 Chinese Remainder Theorem


Let n1 , n2 , . . . , nr be positive integers such that gcd(ni , nj ) = 1 for The moduli n1 , n2 , . . . , nr are said
i %= j. Then the system of linear congruences to be pairwise relatively prime.

x ≡ b1 (mod n1 ) ; x ≡ b2 (mod n2 ) ; ... ; x ≡ br (mod nr )


has a simultaneous solution which is unique modulo n1 n2 . . . nr .

Proof of Theorem 4.1


We shall prove the theorem by first constructing a solution and then
showing that it is unique modulo n1 n2 . . . nr .
N
Let N = n1 n2 . . . nr and Nk = , for k = 1, 2, . . . , r. Then, since
nk
gcd(ni , nk ) = 1 for each i %= k, it follows that
gcd(Nk , nk ) = gcd(n1 n2 . . . nk−1 nk+1 . . . nr , nk ) = 1,
and so the linear congruence Nk x ≡ 1 (mod nk ) has a unique solution
modulo nk . Let this solution be xk , so Nk xk ≡ 1 (mod nk ).
We shall show that the integer
x0 = b1 N1 x1 + b2 N2 x2 + · · · + br Nr xr
satisfies each of the congruences. To achieve this we evaluate x0 modulo nk ,
for each k = 1, 2, 3, . . . , r.
We start by noting that, whenever i %= k, since nk divides Ni , we have
Ni ≡ 0 (mod nk ). Consequently
x0 ≡ bk Nk xk (mod nk ) , for each k = 1, 2, . . . , r,
as each of the remaining terms in the sum is congruent modulo nk to 0.
Finally, since xk was found such that Nk xk ≡ 1 (mod nk ), we have
x0 ≡ bk (mod nk )
as claimed.

23
It remains to show that the discovered solution is unique modulo the
product n1 n2 . . . nr . To this end suppose that x" is a second simultaneous
solution of the system, that is,
x0 ≡ x" ≡ bk (mod nk ) , for each k = 1, 2, . . . , r.
This implies that each nk divides x" − x0 , whereupon the fact that the
moduli are pairwise relatively prime gives us that
n1 n2 . . . nr divides x" − x0 .
This amounts to
x" ≡ x0 (mod n1 n2 . . . nr )
exactly as required.

To illustrate the proof of the Chinese Remainder Theorem we trace its steps
in an example.

Example 4.2
Solve the system of simultaneous linear congruences
x ≡ 5 (mod 6) ; x ≡ 4 (mod 11) ; x ≡ 3 (mod 17) .
The given values of the variables in the proof are:
coefficients: b1 = 5, b2 = 4, b3 = 3;
moduli: n1 = 6, n2 = 11, n3 = 17.
The calculated values are:
N = 6 × 11 × 17 = 1122; N1 = 11 × 17 = 187;
N2 = 6 × 17 = 102; N3 = 6 × 11 = 66.
The values xi are obtained by solving the linear
congruences Ni x ≡ 1 (mod ni ).
N1 x ≡ 1 (mod n1 ) ↔ 187x ≡ 1 (mod 6)
↔ x ≡ 1 (mod 6) ; so x1 = 1.
N2 x ≡ 1 (mod n2 ) ↔ 102x ≡ 1 (mod 11)
↔ 3x ≡ 1 (mod 11)
↔ x ≡ 4 (mod 11) ; so x2 = 4.
N3 x ≡ 1 (mod n3 ) ↔ 66x ≡ 1 (mod 17)
↔ −2x ≡ −16 (mod 17)
↔ x ≡ 8 (mod 17) ; so x3 = 8.
Therefore
x0 = 5 × 187 × 1 + 4 × 102 × 4 + 3 × 66 × 8 = 4151
≡ 785 (mod 1122) . "

Problem 4.1
Find the least positive integer n such that 32 divides 2n + 3, 42 divides
3n + 4 and 52 divides 4n + 5.

4.2 Solving simultaneous congruences


One situation in which systems of simultaneous linear congruences can be
introduced is when confronted with a problem of solving a single linear
congruence where the modulus is large and composite. To see how this
works let n have prime decomposition pk11 pk22 . . . pkr r and compare the linear
congruence
ax ≡ b (mod n)

24
and the system

ax ≡ b mod pk11 ; ax ≡ b mod pk22 ; ... ; ax ≡ b mod pkr r .

Certainly any integer x which satisfies ax ≡ b (mod n) also satisfies each


congruence in the system because pki i divides n for each i. On the other
hand, since the pi are pairwise relatively prime, repeated use of the corollary
of Theorem 1.3 tells us that any solution of the simultaneous system must
satisfy ax ≡ b (mod n). So the two are equivalent.
We shall solve a problem of this sort in Example 4.3, which follows. However,
in this example we shall abandon the formal approach of Example 4.2 and
Problem 4.1 in which we traced the explicit construction of a solution as
given in the proof of the Chinese Remainder Theorem. The method we shall
adopt here, like our solution of Sun-Tsu’s problem at the beginning of the
section, will not require the same amount of careful arithmetic. Indeed, we
often treat the Chinese Remainder Theorem as an important theoretical
result which confirms the existence of solutions, but apply other methods,
like the one we are about to illustrate, to discover what those solutions are.

Example 4.3
Solve the linear congruence 3x ≡ 5 (mod 1001).
Observing that 1001 = 7 × 11 × 13, we seek the simultaneous solution of
3x ≡ 5 (mod 7) ; 3x ≡ 5 (mod 11) ; 3x ≡ 5 (mod 13) .
That is, (having first solved each of these congruences individually),
x ≡ 4 (mod 7) ; x ≡ 9 (mod 11) ; x ≡ 6 (mod 13) .
The positive integers x which satisfy the congruence x ≡ 6 (mod 13) are
x = 6, 19, 32, 45, 58, 71, 84, 97, . . ..
Now 97 is the first of these integers which is congruent modulo 11 to 9, and
consequently, x ≡ 97 (mod 11 × 13) is the unique solution of the final pair of
congruences of the system. The positive integers in this solution set are
x = 97, 240, 383, 526, 669, . . ..
Now 669 is the first of these which is also congruent modulo 7 to 4, and
hence is the smallest positive integer satisfying all three congruences. Hence
x ≡ 669 (mod 7 × 11 × 13)
is the unique solution of the congruence.

Increase by 13 until a
solution of the second
congruence is found.

Increase by 11 x 13 until
a solution of the third
congruence is found. We use the symbol → as a
shorthand for the word ‘implies’.
Plus any multiple
of 7 x 11 x 13.

Figure 4.1 Solving simultaneous linear congruences

25
Problem 4.2
Solve the linear congruence 7x ≡ 9 (mod 165).

There remains one loose end to tidy up. We have seen that when a system
of linear congruences has moduli which are not pairwise relatively prime the
system may be inconsistent and have no solutions. But this is not
necessarily the case. For instance, the system
x ≡ 2 (mod 6) ; x ≡ 5 (mod 9)
involves moduli which are not pairwise relatively prime. However, x = 14
certainly satisfies both congruences, so solutions do exist.

Theorem 4.2
The system of linear congruences
x ≡ b1 (mod n1 ) ; x ≡ b2 (mod n2 )
has a simultaneous solution if, and only if, gcd(n1 , n2 ) divides b2 − b1 .
If a solution exists then it is unique modulo lcm(n1 , n2 ).

Proof of Theorem 4.2


Suppose that the integer x satisfies both
x ≡ b1 (mod n1 ) and x ≡ b2 (mod n2 ) .
That is, there exist integers r and s such that
x − b 1 = n1 r and x − b2 = n2 s.
Eliminating x from this pair of equations leads to
b2 − b1 = n1 r − n2 s.
Now the right-hand side is an integer combination of n1 and n2 and, as such,
is a multiple of gcd(n1 , n2 ). Thus gcd(n1 , n2 ) divides b2 − b1 , and so this is a
necessary condition for the system to have a solution.
To confirm that the condition is sufficient to guarantee a solution, we reverse
the argument. Suppose that
b2 − b1 = k gcd(n1 , n2 ), for some integer k.
Now we know that there exist integers u and v such that
gcd(n1 , n2 ) = un1 + vn2 .
Elimination of gcd(n1 , n2 ) from this pair of equations produces
b1 + kun1 = b2 − kvn2 .
Then
b1 + kun1 = b1 + (ku)n1 ≡ b1 (mod n1 )
and
b1 + kun1 = b2 − (kv)n2 ≡ b2 (mod n2 ) .
So b1 + kun1 satisfies both congruences and confirms that simultaneous
solutions do exist.
Finally, there is the question of uniqueness. Suppose that x1 and x2 are two
solutions. That is
x1 ≡ x2 ≡ b1 (mod n1 ) and x1 ≡ x2 ≡ b2 (mod n2 ) .
Theorem 1.3 now completes the task:
x1 ≡ x2 (mod lcm(n1 , n2 )) .

26
The result of Theorem 4.2 can be generalized to cover any number of
congruences. A proof using mathematical induction is readily available but
is omitted here as the details are somewhat tedious.

Corollary
The system of linear congruences
x ≡ b1 (mod n1 ) ; x ≡ b2 (mod n2 ) ; ... ; x ≡ br (mod nr )
has a simultaneous solution if, and only if, gcd(ni , nj ) divides bj − bi
for each pair i, j of suffixes. If a solution exists it is unique modulo
lcm(n1 , n2 , . . . , nr ).

Problem 4.3
For each of the following systems of simultaneous linear congruences decide
whether or not it has solutions and if so solve the system.
(a) x ≡ 7 (mod 12) ; x ≡ 11 (mod 18) ; x ≡ 1 (mod 23)
(b) x ≡ 4 (mod 12) ; x ≡ 10 (mod 18) ; x ≡ 3 (mod 7)

Throughout the remainder of the course we shall continually be meeting


congruence problems. It may be surprising how often the task of solving
linear congruences crops up in the context of deeper problems.

ADDITIONAL EXERCISES

Section 1
1 Determine the least positive residue and the least absolute residue of
1997
(a) modulo 7;
(b) modulo 17;
(c) modulo 101.

2 Given that k ≡ 1 (mod 12), what is the least positive residue of 6k + 5


(a) modulo 4;
(b) modulo 9;
(c) modulo 12?

3 (a) Give an example to show that ak ≡ bk (mod n) need not imply that
a ≡ b (mod n).
(b) Give an example to show that ak ≡ bk (mod n) and k ≡ j (mod n)
both being true does not necessarily imply that aj ≡ bj (mod n) is
true.

4 Prove by induction that 6n ≡ 5n + 1 (mod 25), for all integers n ≥ 1.

5 Prove that if n ≥ 2 and gcd(a, n) = 1 then the set of integers


{c, c + a, c + 2a, c + 3a, . . . , c + (n − 1)a}
is a complete set of residues modulo n for any integer c.

27
6 What is the remainder when 1111 is divided by
(a) 7;
(b) 17;
(c) 19.

7 Use ideas of congruence to prove that


(a) 29 divides 228 − 1;
(b) 79 divides 339 + 1.

8 In 1659 Fermat asserted that no prime number of the form 3k − 1 can


be written in the form a2 + 3b2 . Use congruence modulo 3 to show that
he was correct.

9 From the definition of congruence alone, prove the following.


If ar ≡ b (mod n) and cr ≡ d (mod n), for some integer r, then
ad ≡ bc (mod n).

Section 2
1 Without carrying out the multiplication find the missing digit (?) in
each of the following products.
(a) 108 × 371 = 40 0(?)8
(b) 1578 × 34 971 = 55 18(?) 238
(c) 4473 × 3(?)9 = 1 426 887 Hint : 11 divides 1 426 887.

2 A and B are two different 7-digit numbers each involving all seven of
the digits 1, 2, 3, 4, 5, 6 and 7. Prove that A does not divide B.

3 Let N > M be two 10-digit numbers formed from the same 10 digits
but in different orders. If X is the sum of the digits of N − M , show
that the sum of the digits of X is 9.

4 Show that 2n divides an integer N if, and only if, 2n divides the
number made up of the last n digits of N .

5 (a) Show that, for all n ≥ 0, 102n ≡ 1 (mod 99) and


102n+1 ≡ 10 (mod 99).
(b) The remainder on dividing a number by 99 can be found in a way
similar to the corresponding result for division by 9, but treating
the digits of the number two at a time. The following examples
illustrate the method:
6239 ≡ 62 + 39 ≡ 101 ≡ 2 (mod 99)
and
54 787 ≡ 5 + 47 + 87 ≡ 139 ≡ 40 (mod 99) .
Use the result in part (a) to show why this test works.
(c) Find a test for divisibility by 101 and use it to determine the
remainders when 62 479 and 9 850 833 are divided by 101.

28
Section 3
1 Solve the following linear congruences.
(a) 8x ≡ 12 (mod 60)
(b) 21x ≡ 35 (mod 47)
(c) 6x ≡ 5 (mod 41)
(d) 5x ≡ 1 (mod 93)

2 Solve the following polynomial congruences.


(a) x3 ≡ 1 (mod 7)
(b) 2x2 + 4x + 5 ≡ 0 (mod 7)

3 Use congruences to solve the following linear Diophantine equations.


(a) 12x + 19y = 7
(b) 17x + 41y = 13

4 There are 19 × 20 congruences of the form ax ≡ b (mod 20), since there


are 19 different choices for a ,≡ 0 (mod 20) and 20 choices for b. For
how many of these congruences does a solution exist, and for how many
congruences is the solution unique?

Section 4
1 Solve the following system of congruences by following the steps in the
proof of the Chinese Remainder Theorem.
x ≡ 1 (mod 4); x ≡ 3 (mod 5); x ≡ 0 (mod 7) .

2 Solve the following systems of congruences by any method.


(a) 2x ≡ 3 (mod 5); 3x ≡ 4 (mod 7); 4x ≡ 9 (mod 11).
(b) x ≡ 1 (mod 4); x ≡ 3 (mod 6); x ≡ 3 (mod 9).

3 Solve the following linear congruence.


19x ≡ 7 (mod 2310)

4 Find the smallest positive integer n such that 32 divides n, 42 divides


n + 1 and 52 divides n + 2.

5 In the arithmetic progression


7, 18, 29, 40, 51, . . .
find the first three consecutive terms which are divisible by 2, 3 and 5
respectively.

6 For which values of c does the following system of congruences have a


simultaneous solution?
5x ≡ c (mod 12); 7x ≡ 2 (mod 30)

7 A band of seventeen pirates stole a sack of gold coins. Attempting to


divide the spoils into equal portions they found that four coins were left
over. A brawl over who should get the extra coins followed and one
pirate was killed. When the spoils were redistributed amongst the
survivors, ten coins were left over. Again an argument developed and
one pirate was killed. But now the spoils divided equally between the
remaining pirates. What was the least number of coins that could have
been stolen?

29
Challenge Problems
1 Let A = 44444444. If B is the sum of the digits of A, C is the sum of
the digits of B and D is the sum of the digits of C, what is D?

2 Find a positive integer such that one-half of it is a square, one-third of


it is a cube and one-fifth of it is a fifth power.

3 Find the final digit of each of the numbers


" %
...(77 )
7
7 
(. . . (((77 )7 )7 )7 . . .)7 and 7
where, in both expressions, the integer 7 occurs 1 001 times. What are
the final two digits of each?

4 Let N be any integer. How can you construct from the digits of N a
number M of at most 3 digits such that N ≡ M (mod 37).

SOLUTIONS TO THE PROBLEMS


Solution 1.1
(a) False, as 3 − 29 = −26, which is not a multiple of 8.
(b) True, as 3 − (−29) = 32 = 4 × 8.
(c) True, as 63 − 37 = 26 = 2 × 13.
(d) True, as 37 − 63 = −26 = (−2) × 13.
(e) True, as 63 − 63 = 0 = 0 × 37. From the definition of divisors
(Definition 4.1 of Unit 1 ) 0 is
(f) False, as 63 − 13 = 50 = 2 × 25, so 63 ≡ 13 (mod 25).
divisible by every positive integer.

Solution 1.2
Since a ≡ b (mod n), let k be the integer such that a − b = kn.
(a) m divides n means that n = mr for some integer r. Therefore
a − b = kn = k(mr) = (kr)m,
which confirms that a ≡ b (mod m).
(b) Multiplying by m:
ma − mb = mkn = k(mn), confirming ma ≡ mb (mod mn),
= (mk)n, confirming ma ≡ mb (mod n).
(c) Dividing by d:
a b n a b " n% a b n
− = k , which implies that ≡ mod . Note that , and are integers.
d d d d d d d d d
(d) Let gcd(a, n) = d1 and gcd(b, n) = d2 . Since d1 divides a, and d1 divides
n, it follows that d1 divides a − kn; that is d1 divides b. But then d1 is a
common divisor of b and n, and so d1 ≤ d2 .
On the other hand, d2 divides b, and d2 divides n, giving d2 divides
b + kn, that is, d2 divides a. So d2 is a common divisor of a and n, and
so d2 ≤ d1 . Hence the equality d1 = d2 follows.

30
Solutions to the Problems

(e) (a + c) − (b + c) = a − b = kn, and so a + c ≡ b + c (mod n) .


Note that the result in part (e) is just a special, but important, case of
Theorem 1.1(e) in which d = c.

Solution 1.3
(a) The set of least positive residues modulo 10 is
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
The set of least absolute residues modulo 10 is
{−4, −3, −2, −1, 0, 1, 2, 3, 4, 5}.
(b) The set of least positive residues modulo 11 is
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
The set of least absolute residues modulo 11 is
{−5, −4, −3, −2, −1, 0, 1, 2, 3, 4, 5}.

Solution 1.4
(a) Replacing each of the numbers by the least positive residue to which it
is congruent modulo 11, (for instance −3 ≡ 8, 22 ≡ 0, etc), we obtain When there is no ambiguity over
which modulus is involved we shall
{6, 2, −3, 22, 23, −7, 7, 9, 43, −8, 16} ≡ {6, 2, 8, 0, 1, 4, 7, 9, 10, 3, 5}. occasionally, as in this solution, use
the ≡ symbol without its
As the latter is the set of least positive residues modulo 11 the former is accompanying (mod n).
a complete set of residues modulo 11.
(b) As 102 = 100 ≡ 1 and 12 ≡ 1 (mod 11) the eleven numbers do not form
a complete set of residues. In fact only six residue classes are
represented in this set, as 92 ≡ 22 , 82 ≡ 32 , 72 ≡ 42 and 62 ≡ 52 .
(c) Starting from 1, each subsequent number is obtained by doubling. To
avoid calculation of high powers of 2 we can write down the least
positive residue for each of the numbers by systematically ‘doubling
modulo 11’. The given eleven numbers are congruent modulo 11, in
order, to the following:
0, 1, 2, 4, 8, 16 ≡ 5, 10, 20 ≡ 9, 18 ≡ 7, 14 ≡ 3 and 6. Each time 11 is exceeded the
number is replaced by the least
As these numbers form the set of least positive residues modulo 11, the positive residue and doubling
given set is a complete set of residues. begins again.

Solution 1.5
In Z10 :
[6] + [8] = [6 + 8] = [14] = [4], since 14 ≡ 4 (mod 10) .
[6] × [8] = [6 × 8] = [48] = [8], since 48 ≡ 8 (mod 10) .
Allowing b to take each of the values 0, 1, 2, . . . , 8 and 9 in turn we find that
the corresponding values of [6] × [b] are [0], [6], [2], [8], [4], [0], [6], [2], [8],
and [4]. So [6] × [b] = [8] has the two solutions [b] = [3] and [b] = [8].
Repeating in Z11 :
[6] + [8] = [14] = [3], since 14 ≡ 3 (mod 11) .
[6] × [8] = [48] = [4], since 48 ≡ 4 (mod 11) .
[6] × [b] = [8] has the unique solution [b] = [5].

31
Solutions to the Problems

Solution 1.6
We first note that if n ≥ 7 then 7 divides n! and so n! ≡ 0 (mod 7).
Therefore we have the simplification:
1! + 2! + 3! + · · · + 1000! ≡ 1! + 2! + 3! + · · · + 6! (mod 7)
(which removes all fear of the problem!) Now, working modulo 7, 1! = 1,
2! = 2, 3! = 6, 4! = 24 ≡ 3, 5! = 5 × 4! ≡ 5 × 3 ≡ 1 and
6! = 6 × 5! ≡ 6 × 1 = 6. And so,
1! + 2! + 3! + · · · + 1000! ≡ 1 + 2 + 6 + 3 + 1 + 6 = 19 ≡ 5 (mod 7) ,
and the remainder on dividing by 7 is 5.

Solution 1.7
a2 − 1 is divisible by 24 precisely when a2 − 1 ≡ 0 (mod 24) or equivalently,
adding 1 to both sides and appealing to Theorem 1.1(d), when
a2 ≡ 1 (mod 24). So our task is to show that any integer, a, which is
divisible neither by 2 nor by 3 must satisfy a2 ≡ 1 (mod 24).
The Division Algorithm tells us that a can be written as
a = 24q + r, where 0 ≤ r ≤ 23.
But, written in this way, a is divisible by 2 when r is even, and is divisible
by 3 when r is divisible by 3. There are just eight values of r which are not
divisible by either 2 or 3, namely r = 1, 5, 7, 11, 13, 17, 19 and 23. For a to
be not divisible by either 2 or 3 it must be congruent modulo 24 to one of
these eight values. Thus we have, replacing each of the last four listed values
by its least absolute residue,
a ≡ ±1, ±5, ±7, ±11 (mod 24) .
Now appealing to Theorem 1.1(f),
a2 ≡ 1, 25, 49 or 121 (mod 24) .
But each of these numbers has remainder 1 when divided by 24, and the
result follows.

Solution 1.8
(a) We wish to cancel the common divisor 6. As gcd(6, 30) = 6, we also
divide the modulus by 6:
6x ≡ 18 (mod 30) ↔ x ≡ 3 (mod 5) .
(b) In order to cancel the common divisor 10, the modulus has to be divided
by gcd(10, 45) = 5. So,
20x ≡ 30 (mod 45) ↔ 2x ≡ 3 (mod 9) .
(c) The common divisor 13 can be cancelled without adjustment to the
modulus, since gcd(13, 60) = 1. So
52x ≡ 39 (mod 60) ↔ 4x ≡ 3 (mod 60) .

Solution 2.1
(a) (i) N ≡ 9 + 7 + 2 + 3 ≡ 3 (mod 9) ;
M ≡ 1 + 8 + 0 + 5 + 6 ≡ 2 (mod 9) ;
N + M ≡ 3 + 2 ≡ 5 (mod 9) ;
N − M ≡ 3 − 2 ≡ 1 (mod 9) .
Hence the required remainders are 3, 2, 5 and 1 respectively.

32
Solutions to the Problems

(ii) N ≡ 3 − 2 + 7 − 9 ≡ −1 ≡ 10 (mod 11) ;


M ≡ 6 − 5 + 0 − 8 + 1 ≡ −6 ≡ 5 (mod 11) ;
N + M ≡ 10 + 5 ≡ 4 (mod 11) ;
N − M ≡ 10 − 5 ≡ 5 (mod 11) .
Hence the required remainders are 10, 5, 4 and 5 respectively.
(b) N × M ≡ 3 × 2 ≡ 6 (mod 9), and so the number on the right-hand side
of the equation has to be congruent modulo 9 to 6.
1 + 7 + 5 + (?) + 5 + 8 + 4 + 8 + 8 = 46 + (?) ≡ 1 + (?) ≡ 6 (mod 9) ,
from which it follows that the missing digit (?) can only be 5.

Solution 2.2
Let N = a2m−1 a2m−2 . . . a2 a1 a0 so that M = a0 a2m−1 a2m−2 . . . a2 a1 . Since
N and M comprise the same 2m digits, the 9-test gives
N ≡ M ≡ a0 + a1 + a2 + · · · + a2m−2 + a2m−1 (mod 9) ,
and so N − M ≡ 0 (mod 9), that is, 9 divides N − M .
Applying the 11-test:
N ≡ a0 − a1 + a2 − · · · + a2m−2 − a2m−1 (mod 11)
whilst
M ≡ a1 − a2 + a3 · · · − a2m−2 + a2m−1 − a0 (mod 11) .
So N + M ≡ 0 (mod 11). That is, 11 divides N + M .
Finally, since N 2 − M 2 = (N − M )(N + M ) we have that 9 divides
N 2 − M 2 and 11 divides N 2 − M 2 . As gcd(9, 11) = 1, the Corollary to
Theorem 1.3 allows us to conclude that 99 divides N 2 − M 2 .

Solution 3.1
(a) We evaluate P1 (x) for each of the least positive residues modulo 7,
namely x = 0, 1, 2, 3, 4, 5 and 6.
02 + 3 × 0 + 4 = 4 ≡ 4 (mod 7)
12 + 3 × 1 + 4 = 8 ≡ 1 (mod 7)
22 + 3 × 2 + 4 = 14 ≡ 0 (mod 7)
32 + 3 × 3 + 4 = 22 ≡ 1 (mod 7)
42 + 3 × 4 + 4 = 32 ≡ 4 (mod 7)
52 + 3 × 5 + 4 = 44 ≡ 2 (mod 7)
62 + 3 × 6 + 4 = 58 ≡ 2 (mod 7)
So P1 (x) ≡ 0 (mod 7) has the one solution x ≡ 2 (mod 7).
(b) We need to evaluate P2 (x) on a complete set of residues. This time we The fact that P (a) = P (−a)
shall choose the least absolute residues modulo 5, namely influences the use of the least
x = −2, −1, 0, 1 and 2. absolute residues for, as you see, it
effectively reduces the number of
P2 (0) = −1 ≡ 4 (mod 5) residues to be checked.
P2 (1) = P2 (−1) = 1 − 1 ≡ 0 (mod 5)
P2 (2) = P2 (−2) = 16 − 1 ≡ 0 (mod 5)
P2 (x) ≡ 0 (mod 5) has the four solutions x ≡ 1, 2, −2 and −1 (mod 5).
That is, alternatively, x ≡ 1, 2, 3 and 4 (modulo 5).

33
Solutions to the Problems

Solution 3.2
(a) Since gcd(5, 10) = 5 and 5 does not divide 13, this congruence has no
solutions.
(b) Since gcd(5, 13) = 1, this congruence has a unique solution.
(c) Since gcd(10, 30) = 10 and 10 does not divide 5, this congruence has no
solutions.
(d) Since gcd(27, 24) = 3 and 3 divides 318, this congruence has three
solutions.
Solution 3.3
(a) The congruence has a unique solution modulo 53.
28x ≡ 49 (mod 53) ↔ 4x ≡ 7 (mod 53) Step 3
↔ 4x ≡ 60 (mod 53) Step 4
↔ x ≡ 15 (mod 53) Step 3
(b) gcd(34, 52) = 2 and 2 does not divide 19 so the congruence has no
solutions.
(c) The congruence has a unique solution modulo 19.
137x ≡ 96 (mod 19) ↔ 4x ≡ 1 (mod 19) Step 4 137 ≡ 4 (mod 19) and
↔ 4x ≡ 20 (mod 19) Step 4 96 ≡ 1 (mod 19).

↔ x ≡ 5 (mod 19) Step 3


(d) The congruence has a unique solution modulo 53.
51x ≡ 8 (mod 53) ↔ −2x ≡ 8 (mod 53) Step 4
↔ 2x ≡ −8 (mod 53) Step 5 Rather than multiply through by
−1 and then divide by 2 we could
↔ x ≡ −4 (mod 53) Step 3 simply divide through by −2.
↔ x ≡ 49 (mod 53) Step 4
(e) As gcd(18, 69) = 3 and 3 divides 39, this congruence has three solutions
modulo 69.
18x ≡ 39 (mod 69) ↔ 6x ≡ 13 (mod 23) Step 2 We still use the equivalence symbol
↔ despite the different moduli,
↔ 6x ≡ 36 (mod 23) Step 4
because an integer x is a solution
↔ x ≡ 6 (mod 23) Step 3 of the previous congruence if, and
only if, it is a solution of the
↔ x ≡ 6, 29, 52 (mod 69)
following congruence.
The final step gives the derived solution in terms of the original modulus.
Solution 4.1
Expressed in terms of congruence the three conditions to be satisfied are
2n + 3 ≡ 0 (mod 9) ; 3n + 4 ≡ 0 (mod 16) ; 4n + 5 ≡ 0 (mod 25) .
Solving these individually we have the equivalent system
n ≡ 3 (mod 9) ; n ≡ 4 (mod 16) ; n ≡ 5 (mod 25) .
The variables in the proof of the Chinese Remainder Theorem are:
b1 = 3, b2 = 4, b3 = 5, n1 = 9, n2 = 16, n3 = 25, N = 3600,
N1 = 400, N2 = 225, N3 = 144.
N1 x = 400x ≡ 1 (mod 9) ↔ 4x ≡ 1 (mod 9)
↔ x ≡ 7 (mod 9) , so x1 = 7.
N2 x = 225x ≡ 1 (mod 16) ↔ x ≡ 1 (mod 16) , so x2 = 1.
N3 x = 144x ≡ 1 (mod 25) ↔ 19x ≡ 1 ≡ 76 (mod 25)
↔ x ≡ 4 (mod 25) , so x3 = 4.
Therefore
x0 = 3 × 400 × 7 + 4 × 225 × 1 + 5 × 144 × 4 = 12 180 ≡ 1380 (mod 3600)
and the least positive solution is n = 1380.

34
Solution 4.2
As 165 = 3 × 5 × 11 we begin by solving the linear congruence to each of the
moduli 3, 5 and 11.
7x ≡ 9 (mod 3) ↔ x ≡ 0 (mod 3)
7x ≡ 9 (mod 5) ↔ x ≡ 2 (mod 5)
7x ≡ 9 (mod 11) ↔ x ≡ 6 (mod 11)
Our task is now to solve the three congruences on the right-hand side
simultaneously.
x ≡ 6 (mod 11) =⇒ x = 6, 17, . . . ,
increasing in steps of 11 until we reach a solution of the second congruence.
x ≡ 2 (mod 5) =⇒ x = 17, 72, . . . ,
increasing in steps of 11 × 5 = 55 until we reach a solution of the remaining
congruence.
x ≡ 0 (mod 3) =⇒ x ≡ 72 (mod 165) .

Solution 4.3
(a) This system has no solutions since gcd(12, 18) = 6 and 6 does not divide
11 − 7 = 4.
(b) This system has solutions since gcd(12, 18) divides 10 − 4, gcd(7, 12) = 1
(which divides all integers) and gcd(7, 18) = 1.
x ≡ 10 (mod 18) → x = 10, 28, . . . ,
x ≡ 4 (mod 12) → x = 28, 64, 100, 136, . . . ,
increasing in steps of lcm(12, 18) = 36,
x ≡ 3 (mod 7) → x ≡ 136, 388, 640, . . . ,
increasing in steps of 7 × 36 = 252.
The solution x ≡ 136 (mod 252) is unique.

SOLUTIONS TO ADDITIONAL
EXERCISES

Section 1
1 (a) Since 1997 = 7 × 285 + 2,
the least positive residue is 2, and
the least absolute residue is 2.
(b) Since 1997 = 17 × 117 + 8,
the least positive residue is 8, and
the least absolute residue is 8.
(c) Since 1997 = 101 × 19 + 78,
the least positive residue is 78, and
the least absolute residue is 78 − 101 = −23.

35
2 If k ≡ 1 (mod 12) then k = 12r + 1, for some integer r. Hence
6k + 5 = 72r + 11.
(a) As 4 divides 72, we have 6k + 5 ≡ 11 ≡ 3 (mod 4), and so 3 is the
required least positive residue.
(b) As 9 divides 72, we have 6k + 5 ≡ 11 ≡ 2 (mod 9), and so 2 is the
required least positive residue.
(c) As 12 divides 72, we have 6k + 5 ≡ 11 (mod 12), and so 11 is the
required least positive residue.

3 (a) 12 ≡ 62 (mod 7) but it is not the case that 1 ≡ 6 (mod 7).


(b) 12 ≡ 22 (mod 3) and 2 ≡ 5 (mod 3), but 15 *≡ 25 (mod 3).

4 Let P (n) be the proposition 6n ≡ 5n + 1 (mod 25).


P (1) claims that 6 ≡ 6 (mod 25) which is trivially true. We continue by
assuming that P (k) is true and investigate P (k + 1).
6k+1 = 6 × 6k ≡ 6 × (5k + 1), by the induction hypothesis,
≡ 30k + 6 (mod 25)
≡ 5k + 6 (mod 25)
≡ 5(k + 1) + 1 (mod 25) ,
as required.
The Principle of Mathematical Induction confirms that P (n) is true for
all integers n ≥ 1.

5 The set of n numbers will form a complete set of residues modulo n


provided no two of them are congruent modulo n. So, aiming for a
contradiction, suppose that two of the numbers are congruent
modulo n, say
c + ra ≡ c + sa (mod n) , where 0 ≤ s < r < n.
The definition of congruence would then give
n divides (c + ra) − (c + sa).
That is,
n divides (r − s)a.
But gcd(a, n) = 1, and so Euclid’s Lemma leads to
n divides r − s,
which is impossible since 0 < r − s < n.

6 There is no unique set of steps to answer these questions. You might


well have found different ways of grouping the terms from those in the
solutions which follow.
(a) As 11 ≡ 4 (mod 7), we have 1111 ≡ 411 (mod 7).
Now 42 = 16 ≡ 2 (mod 7) and so
1111 ≡ 411 ≡ (42 )5 × 4 ≡ 25 × 4 ≡ 32 × 4 ≡ 4 × 4 ≡ 2 (mod 7) .
So the remainder is 2.
(b) As 112 = 121 ≡ 2 (mod 17), we have
1111 = (112 )5 × 11 ≡ 25 × 11 ≡ (−2) × 11 ≡ −5 ≡ 12 (mod 17) .
So the remainder is 12.

36
(c) 1111 ≡ (−8)11 ≡ ((−8)2 )5 × (−8) ≡ 75 × (−8) (mod 19)
≡ 72 × 72 × 7 × (−8) ≡ 11 × 11 × (−56) (mod 19)
≡ (−8)2 × 1 ≡ 64 ≡ 7 (mod 19) .
So the remainder is 7.

7 (a) 228 ≡ (25 )5 × 23 ≡ 35 × 23 ≡ 27 × 9 × 8 (mod 29)


≡ (−2) × 14 ≡ −28 ≡ 1 (mod 29) ,
which amounts to saying that 29 divides 228 − 1.
(b) 339 ≡ (34 )9 × 33 ≡ 29 × 33 ≡ (8 × 9) × (32 × 3) × 2 ≡ (−7) × (17) × 2 (mod 79)
≡ (−119) × 2 ≡ (−40) × 2 ≡ −80 ≡ −1 (mod 79) .
It follows that 79 divides 339 + 1.

8 Since any square is congruent modulo 3 to either 0 or 1 it follows that


a2 + 3b2 is congruent modulo 3 to either 0 or 1 (since 3b2 ≡ 0 (mod 3)).
But 3k − 1 ≡ 2 (mod 3), and so a2 + 3b2 cannot be equal to 3k − 1 for
any integer k, regardless of whether or not it is prime.

9 The congruences ar ≡ b (mod n) and cr ≡ d (mod n) tell us that there


exist integers k and s such that ar − b = kn and cr − d = sn.
Substituting for b from the first of these equations and for d from the
second gives
ad − bc = a(cr − sn) − (ar − kn)c = n(kc − as),
which shows that ad ≡ bc (mod n).

Section 2
1 (a) As 108 is divisible by 9, the right-hand side must be divisible by 9.
Hence, by adding up the digits, 4 + 0 + 0 + (?) + 8 ≡ 0 (mod 9) and
the only value of the digit (?) which renders this possible is 6.
(b) Checking the calculation modulo 9,
1578 × 34 971 ≡ 3 × 6 ≡ 0 (mod 9) ,
and so the sum of the digits on the right-hand side must be
divisible by 9. Thus
5 + 5 + 1 + 8 + (?) + 2 + 3 + 8 ≡ 32 + (?) ≡ 5 + (?) ≡ 0 (mod 9) ,
giving (?) = 4.
(c) The right-hand side is divisible by 11 and so the left-hand side must
be divisible by 11. Now 4473 is not divisible by 11, and so 3(?)9
must be. Hence (?) = 1 is the only possibility.

2 Aiming for a contradiction, suppose that A divides B, say B = nA for


some integer n. Now as A comprises the digits 1 to 7 we have
A ≡ 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28 ≡ 1 (mod 9)
and similarly B ≡ 1 (mod 9).
The equation B = nA then gives n ≡ 1 (mod 9). But n = 1 gives
B = A, which is not the case, and so n ≥ 10. However this is impossible
since that forces B to have more digits than A. This contradiction
shows that no such n can exist and so A does not divide B.

37
3 The key here is to note that, as M and N have the same collection of
digits, N ≡ M (mod 9) or, what amounts to the same thing,
N − M ≡ 0 (mod 9). But X is the sum of the digits of N − M and so
X ≡ 0 (mod 9). Now N − M is a number with ten (or fewer) digits and
so X ≤ 90. Of all numbers not exceeding 90, the maximum sum of the
digits is 17 (achieved by the number 89). X cannot be equal to 0 as
that would happen if, and only if, N = M .
Let Y be the sum of the digits of X. Then
Y ≡ X ≡ 0 (mod 9) , where 0 < Y < 18.
Thus the only possibility is Y = 9.

4 Dividing N , by 10n , the Division Algorithm gives integers q and r such For example, to extract the final
that three digits from 1 234 567 we write
1 234 567 = 1234 × 103 + 567.
N = 10n q + r, 0 ≤ r < 10n .
Because of the restriction on r, it follows that r is the number made up
of the last n digits of N .
Now 2n divides 10n and so, taking congruence modulo 2n ,
N ≡ r (mod 2n ) .
Thus N ≡ 0 (mod 2n ) if, and only if, r ≡ 0 (mod 2n ), that is, 2n
divides N if, and only if, 2n divides r, the number made up of the last
n digits of N .

5 (a) 102n = (102 )n ≡ 1n ≡ 1 (mod 99),


102n+1 = 10 × 102n ≡ 10 (mod 99).
(b) Let
N = am am−1 . . . a2 a1 a0
= a0 + a1 10 + a2 102 + a3 103 + · · · + am−1 10m−1 + am 10m
= (10a1 + a0 ) + 102 (10a3 + a2 ) + 104 (10a5 + a4 ) + . . . . The last term in the summation is
2n 10m−1 (10am + am−1 ) if m is odd
Utilizing the fact that 10 = 1 (mod 99) we have and 10m (0 + am ) if m is even.
N ≡ (10a1 + a0 ) + (10a3 + a2 ) + (10a5 + a4 ) + . . . (mod 99) ,
and the remainder on dividing by 99 can be obtained from this sum
of pairs of digits.
(c) Working modulo 101, the successive powers of 10 are:
100 ≡ 1, 101 ≡ 10, 102 ≡ −1, 103 ≡ −10, 104 ≡ 1, 105 ≡ 10, etc.
Hence
N = am am−1 . . . a2 a1 a0
= a0 + a1 10 + a2 102 + a3 103 + · · · + am−1 10m−1 + am 10m
≡ (10a1 + a0 ) − (10a3 + a2 ) + (10a5 + a4 ) − · · · (mod 101) ,
and the remainder on dividing by 101 is obtained from this
alternating sum of pairs of digits. Now
62 479 ≡ 79 − 24 + 6 ≡ 61 (mod 101) and
9 850 833 ≡ 33 − 8 + 85 − 9 ≡ 101 ≡ 0 (mod 101) ,
so the remainders are 61 and 0 respectively.

38
Section 3
1 (a) 8x ≡ 12 (mod 60) ↔ 2x ≡ 3 (mod 15)
↔ 2x ≡ 18 (mod 15)
↔ x ≡ 9 (mod 15)
↔ x ≡ 9, 24, 39, 54 (mod 60)
(b) 21x ≡ 35 (mod 47) ↔ 3x ≡ 5 (mod 47)
↔ 3x ≡ −42 (mod 47)
↔ x ≡ −14 ≡ 33 (mod 47)
(c) 6x ≡ 5 (mod 41) ↔ 42x ≡ 35 (mod 41)
↔ x ≡ 35 (mod 41)
(d) 5x ≡ 1 (mod 93) ↔ 95x ≡ 19 (mod 93)
↔ 2x ≡ 112 (mod 93)
↔ x ≡ 56 (mod 93)

2 (a) Working modulo 7 gives:


03 ≡ 0, 13 ≡ 1, 23 ≡ 1, 33 ≡ 6, 43 ≡ 1, 53 ≡ 6 and 63 ≡ 6.
Therefore the equation x3 ≡ 1 (mod 7) has solutions
x ≡ 1, 2, 4 (mod 7).
(b) The value of 2x2 + 4x + 5 (mod 7) for each of the seven values of x
in a complete set of residues is given in the following table.
x 0 1 2 3 4 5 6
2x2 + 4x + 5 5 4 0 0 4 5 3
Hence 2x2 + 4x + 5 ≡ 0 has the two solutions x ≡ 2, 3 (mod 7).

3 (a) 12x + 19y = 7.


The obvious moduli to try are 12 and 19 as each of these eliminates
one of the variables.
Writing this equation as a congruence modulo 12:
19y ≡ 7 (mod 12) ,
which gives
y ≡ 1 (mod 12) .
Substituting y = 1 in the original equation gives x = −1, and so the
general solution is
x = −1 + 19k, y = 1 − 12k, k ∈ Z.
(b) 17x + 41y = 13.
Writing this equation modulo 17 we have
41y ≡ 13 (mod 17) ↔ 7y ≡ 13 (mod 17)
↔ 35y ≡ 65 (mod 17) multiplying by 5
↔ y ≡ 14 ≡ −3 (mod 17) .
Substituting y = −3 in the original equation gives x = 8, and hence
the general solution is
x = 8 + 41k, y = −3 − 17k, k ∈ Z.

39
4 Take the uniqueness first. The congruence ax ≡ b (mod 20) has a
unique solution if, and only if, gcd(a, 20) = 1; that is, when
a = 1, 3, 7, 9, 11, 13, 17 and 19. For each of these eight values of a there
are twenty values of b, making 160 congruences in total for which the
solution is unique.
The congruence has gcd(a, 20) solutions whenever gcd(a, 20) divides b.
So consider the possible values of gcd(a, 20) in turn.
gcd(a, 20) = 1 leads to 160 solvable congruences, as already seen.
gcd(a, 20) = 2 when a = 2, 6, 14 and 18. For each of these four values of
a the congruence is solvable provided b takes one of the ten even values
0, 2, 4, 6, 8, 10, 12, 14, 16 or 18. Hence there are 40 congruences with
solutions.
gcd(a, 20) = 4 when a = 4, 8, 12 and 16. For each of these four values of
a the congruence has solutions when b takes one of the five values 0, 4,
8, 12 or 16 making 20 congruences in all.
gcd(a, 20) = 5 when a = 5 or 15. For each of these two values of a the
congruence has solutions if b takes one of the values 0, 5, 10 or 15
making 8 congruences in all.
gcd(a, 20) = 10 when a = 10. In this case the congruence is solvable
when b = 0 or 10, making 2 congruences in all.
In all there are 230 congruences which have solutions.

Section 4
1 Following the proof of the Chinese Remainder Theorem, the variables
are: n1 = 4, n2 = 5, n3 = 7, N = 4 × 5 × 7 = 140, N1 = 35, N2 = 28,
N3 = 20, b1 = 1, b2 = 3, b3 = 0.
N1 x1 ≡ 1 (mod n1 ) ↔ 35x1 ≡ 1 (mod 4)
↔ 3x1 ≡ 1 (mod 4) , so x1 = 3.
N2 x2 ≡ 1 (mod n2 ) ↔ 28x2 ≡ 1 (mod 5)
↔ 3x2 ≡ 1 (mod 5) , so x2 = 2.
N3 x3 ≡ 1 (mod n3 ) ↔ 20x3 ≡ 1 (mod 7)
↔ −1x3 ≡ 1 (mod 7) , so x3 = 6.

The solution is
x0 ≡ 1 × 35 × 3 + 3 × 28 × 2 + 0 × 20 × 6 ≡ 273 ≡ 133 (mod 140) .
The smallest positive integer solution is 133.

2 (a) We first solve the three congruences individually.


2x ≡ 3 (mod 5) ↔ x ≡ 4 (mod 5)
3x ≡ 4 (mod 7) ↔ x ≡ 6 (mod 7)
4x ≡ 9 (mod 11) ↔ x ≡ 5 (mod 11)
Now,
x ≡ 5 (mod 11) → x = 5, 16, 27, . . . ,
increasing by 11 to a solution of second congruence,

x ≡ 6 (mod 7) → x = 27, 104, . . . ,


increasing by 11 × 7 = 77 to a solution of congruence remaining,
and
x ≡ 4 (mod 5) → x ≡ 104 (mod 385) .

40
(b) As the moduli are not pairwise relatively prime a little more care
must be taken with this one.
x ≡ 1 (mod 4) and x ≡ 3 (mod 6) have a unique simultaneous
solution modulo 12 (the least common multiple of 4 and 6), since
gcd(4, 6) = 2 divides the difference 3 − 1. By inspection this
solution is x ≡ 9 (mod 12).
x ≡ 9 (mod 12) and x ≡ 3 (mod 9) have a unique simultaneous
solution modulo 36 (the least common multiple of 12 and 9), since
gcd(12, 9) = 3 divides the difference 9 − 3.
x ≡ 9 (mod 12) → x = 9, 21, . . . ,
and
x ≡ 3 (mod 9) → x ≡ 21 (mod 36) .

3 2310 = 2 × 3 × 5 × 7 × 11 and so we require the simultaneous solution


of the system:
19x ≡ 7 (mod 2) ; 19x ≡ 7 (mod 3) ; 19x ≡ 7 (mod 5) ;
19x ≡ 7 (mod 7) ; 19x ≡ 7 (mod 11) .
Solving these individually gives the equivalent system:
x ≡ 1 (mod 2) ; x ≡ 1 (mod 3) ; x ≡ 3 (mod 5) ;
x ≡ 0 (mod 7) ; x ≡ 5 (mod 11) .
Now
x ≡ 1 (mod 2) → x = 1, . . . , increasing in steps of 2,
x ≡ 1 (mod 3) → x = 1, 7, 13, . . . , increasing in steps of 6, The order in which the individual
congruences are incorporated does
x ≡ 3 (mod 5) → x = 13, 43, 73, 103, 133, . . . ,
not matter. We have usually
increasing in steps of 30, started with the one with largest
modulus, but here we have chosen
x ≡ 0 (mod 7) → x = 133, 343, 553, 763, 973, . . . ,
the opposite order.
increasing in steps of 210.
Finally,
x ≡ 5 (mod 11) → x ≡ 973 (mod 2310) .

4 Translated into a problem in simultaneous congruences we have to solve


the system:
n ≡ 0 (mod 9) ; n ≡ 15 (mod 16) ; n ≡ 23 (mod 25) .
Now
n ≡ 23 (mod 25) → n = 23, 48, 73, 98, 123, 148, 173, 198, 223, . . . ,
increasing in steps of 25,
n ≡ 15 (mod 16) → n = 223, 623, 1023, 1423, 1823, 2223, . . . ,
increasing in steps of 16 × 25 = 400.
Finally
n ≡ 0 (mod 9) → n = 2223 (mod 3600) .

41
5 The arithmetic progression comprises numbers of the form 11k + 7, so
three consecutive terms of the sequence are 11n + 7, 11n + 18 and
11n + 29. Our task is therefore to solve, for n, the system of linear
congruences:
11n + 7 ≡ 0 (mod 2) ; 11n + 18 ≡ 0 (mod 3) ; 11n + 29 ≡ 0 (mod 5) ,
which, after simplification becomes
n ≡ 1 (mod 2) ; n ≡ 0 (mod 3) ; n ≡ 1 (mod 5) .
The first and third of these congruences require that n ≡ 1 (mod 10), so
n = 1, 11, 21, . . . .
The first number in this sequence to satisfy the remaining congruence,
n ≡ 0 (mod 3), is n = 21. The three numbers in the arithmetic
sequence are therefore 238, 249 and 260.

6 To be in a position to apply Theorem 4.2 we must first solve each


individual congruence.
5x ≡ c (mod 12) ↔ 25x ≡ 5c (mod 12) ↔ x ≡ 5c (mod 12)
7x ≡ 2 (mod 30) ↔ 7x ≡ −28 (mod 30) ↔ x ≡ −4 ≡ 26 (mod 30)
The system has solutions when gcd(12, 30) divides 26 − 5c; that is,
when 6 divides 26 − 5c.
5c ≡ 26 (mod 6) ↔ 5c ≡ 20 (mod 6) ↔ c ≡ 4 (mod 6) .
So the system has a simultaneous solution when c ≡ 4 (mod 6).

7 The number of gold coins n satisfies each of the congruences


n ≡ 4 (mod 17) ; n ≡ 10 (mod 16) ; n ≡ 0 (mod 15) .
Now
n ≡ 4 (mod 17) → n = 4, 21, 38, 55, 72, 89, 106, . . .,
n ≡ 10 (mod 16) → n = 106, 378, 650, 922, 1194, 1466, 1738, 2010, . . . ,
increasing in steps of 16 × 17 = 272,
and
n ≡ 0 (mod 15) → n ≡ 2010 (mod 15 × 16 × 17) .
The least possible number of coins is 2010.

42
INDEX
Z 10
Zn 10 incongruent modulo n 6
≡, *≡ 6 integral polynomial 16
‘equivalent to’ symbol, ↔ 13
‘implies’ symbol, → 32 least absolute residues 9
least positive residues 9
cancellation rule 13 linear congruence 18
casting out nines 14
Chinese Remainder Theorem 23 number of solutions of a polynomial congruence 17
complete set of residues 9
congruence class 9 polynomial congruence 16
congruent modulo n 6 properties of congruence 7

divisibility by 11 15 residue class 9


divisibility by 9 15
simultaneous linear congruences 22
equivalent congruence 20 simultaneous solution 23
Euclid’s Lemma for prime divisors 14 solution by exhaustion 18

43

You might also like