5.3 The Chinese Remainder Theorem
In the previous section we saw how to decide if certain congruences
have solutions, and how to solve them when solutions exist. In this
section we shall consider a certain type of problem in which two
congruences are involved. We begin with an example.
Example 5.3.1
I have a CD collection numbering under , and
recently I reorganized it. Originally the CDs were arranged in
sets of , and there were left over. My new arrangement
groups together at a time, and now there are left over. How
large is my collection?
How can we try to solve this problem? Clearly if is the answer
then it satisfies the two congruences
|
|
|
One approach would be to take the solutions to the first of these
and work through them in turn until we find one which also satisfies
the second. Thus we would work as follows:
|
|
|
Since the problem specified that the number of CDs was less than
, we see that the unique solution is
In general the problem will be to solve simultaneously the pair of
congruences
|
|
|
(5.3.1) |
The trial-and-error approach proved successful in the case above, but
if the numbers were larger it would involve rather a lot of work. We
shall now try to produce a better approach.
Let us consider the case where the moduli and are coprime,
and take such that . If we multiply this
identity by , then we obtain and thus
. On the other hand,
multiplying by , we get , so
that . Hence
is a solution to the first congruence, while
solves the other. Adding up these two separate
solutions, we obtain a number which
satisfies
|
|
|
and
|
|
|
Thus solves the two congruences
simultaneously.
In fact, we can build on this idea to obtain the following description
of all simultaneous solutions to the pair of
congruences (5.3.1) (still under the assumption that
the moduli and are coprime); this result is known as the
Chinese Remainder Theorem.
Theorem 5.3.2
Let , let be coprime,
and write for some . Then an
integer satisfies and if and
only if .
Example 5.3.3
Solve the pair of congruences
and .
Solution. Since , the Chinese Remainder Theorem applies.
We have , , and . We require integers
and such that ; clearly we can take
and here.
We now compute and
|
|
|
|
|
|
|
|
so that the
complete solution to the pair of congruences is
. (As a check, we observe
that and , so that and
.)
Proof. Set . We saw above that and .
Combining this with Lemmas 5.1.7 and 5.1.9, we see that
satisfies and if and
only if and . By definition, this means that
and , or in other words that
is a common multiple of
and . Now Theorem 4.5.5 states that the
common multiples of and are
exactly the multiples of and
because and are
coprime. Hence we conclude that satisfies
and if and only if
, that is, if and only if .
Example 5.3.4
Find the smallest positive integer which satisfies the two congruences
and
simultaneously.
Solution. We use the Euclidean algorithm to find the highest common
factor of and and express it as an integral linear combination of them:
|
|
|
|
|
|
|
|
|
|
|
|
Hence and are coprime, so the Chinese Remainder Theorem
applies, and in the notation introduced therein, we have , , , , and . Thus the pair of congruences has the
solution
|
|
|
Now , so this
simplifies to , and therefore
is the smallest positive simultaneous solution to the two
congruences.
As we have seen, the congruences (5.3.1) can be
solved simultaneously whenever the moduli and are coprime. We
shall now give a complete description of when simultaneous solutions
exist.
Proposition 5.3.5
Let and .
Then the two congruences
|
|
|
can be solved simultaneously if and only if divides
.
Example 5.3.6
-
(i)
The pair of congruences
|
|
|
can be solved simultaneously because divides
-
(ii)
On the other hand, the pair of congruences
|
|
|
cannot be solved simultaneously because
does not divide
Proof. Set .
‘‘’’. Suppose that the two congruences can be
solved simultaneously, so that there exists such that and ; write and , where
. Then and , so that
|
|
|
Since is a common factor of and , Lemma 4.2.13
implies that is also a factor of , and hence of
‘‘’’. Suppose that divides , say
for some . By Bézout’s Theorem, we can write
, where . Define . Then clearly (because ), and also because
|
|
|
so that solves the two congruences
simultaneously.