In this article we shall consider how to solve problems such as
Find all integers that leave a remainder of
when divided by
,
, and
.
You might like to think about this problem for yourself before reading on.
Here is one way to solve the problem. Let
be an integer that
leaves a remainder of
when divided by
,
and
. Then
is divisible by
,
and
. Since
,
and
are coprime
(have no common factors greater than
), any number that is divisible by
all of them must be divisible by their product, which is
. So if
has the required properties then
is divisible by
. This means
that we can write
in the form
(for some integer
).
It remains to check that all such integers work. But if
then
leaves a
remainder of
when divided by
,
, and
. The answer to the
question is therefore all numbers of the form
, where
is an
integer.
So far, so good. We have solved the question. Here is another problem
like this.
Find all integers that leave a remainder of
when divided by
,
a remainder of
when divided by
, and a remainder of
when
divided by
.
Again, try this problem for yourself before you read on.
Whilst similar ideas to those used above will work here, it's getting a bit
trickier. In fact, it's not even obvious that there are any
solutions here. What we'd like is an approach that is easier to generalise,
so that it will be easier to apply it to other questions (and, indeed,
to a general case involving algebra, which is what the Chinese Remainder
Theorem does).
Let's first introduce some notation, so that we don't have to keep writing
"leaves a remainder of ... when divided by". If
is divisible
by
, then write
(mod
). In particular, if
leaves a
remainder of
when divided by
, then we shall write
(mod
). Read this as "
is congruent to
mod
". You can read
more about this in the NRICH article on
Modular
Arithmetic, but you don't need to have read that article in order to
understand this article.
In the new notation, we can write our problem as
Find all integers
such that
Let's invent a way to illustrate this. We'll have axes corresponding to the
numbers by which we are dividing. For example,
We represent the number
on this graph by the point
,
since
(mod
),
(mod
), and
(mod
). Of course, there are lots of numbers that all correspond to
the same point. For example,
(mod
),
(mod
), and
(mod
), so
and
both
correspond to
. (You might like to think about why this
is - we'll return to this soon.)
What we want to do is to find all the numbers corresponding to the
point
.
Let's pause for a moment. Suppose that we have found two numbers, say
and
, that both correspond to the point
. That is,
(mod
), and
(mod
), and
(mod
). Then
divides
, and
divides
, and
divides
. Since
,
and
are coprime, we see
that
divides
. So if we have two solutions,
then they must differ by a multiple of
. In fact, if
is a solution,
then so is
, for any integer
. Check this yourself - it's
not too hard. (Notice that the two numbers that I picked earlier that both
correspond to the point
differ by
.)
What this tells us is that we only need to find one solution, as we can
then find all the others by adding and subtracting multiples of
. So
we shall concentrate our attention on finding one number that corresponds
to the point
.
Suppose that I have a number
that corresponds to the point
,
and a number
that corresponds to the point
. Then
corresponds to the point
(reducing
mod
,
mod
and
mod
where necessary). Also, if
is any
integer, then
corresponds to the point
(again
reducing co-ordinates where necessary). You should check these statements
yourself, using the definition of what it means for a number to correspond
to a point.
This means that if we have a number
corresponding to the point
, a number
corresponding to
, and a number
corresponding to
, then
will be a number
corresponding to the point
. In fact, if we can find the numbers
,
and
, then we'll be able to find numbers corresponding to
all points, which would be rather good! So let's find
,
and
.
We want
that satisfies
(mod
),
(mod
),
and
(mod
). The last two congruences tell us that
must be divisible by both
and
, so must be
for some integer
. We are now left with the task of finding
such that
(mod
), i.e.,
(mod
). Multiplying both sides by
(and using the fact that
(mod
)), we get
(mod
).
Let's try
. Then
, and
has the properties
we want. In a very similar way, we get
and
. From this, we obtain
. By the above, we know that we may subtract multiples of
, so the smallest positive solution is
, and the integer solutions
are all the numbers of the form
, where
is an integer.
Before we move on to the general situation, let's consider whether we can
always find a number corresponding to the point
(regardless of
the moduli on the axes). The answer is of course "no". For example, if
I have
on the
-axis and
on the
-axis, then I cannot find a
number corresponding to
, as it would have to be congruent to
(mod
) (that is, odd) and congruent to
(mod
) (that is,
divisible by
), which is clearly absurd.
Now let's move on to the Chinese Remainder Theorem itself.
Theorem Let
,
, ..., and
be distinct primes.
For any integers
,
, ...,
, there is an integer
with
and
is unique mod
.
Don't panic about the"unique mod
" bit. All this
means is that all of the solutions differ by multiples of
.
You might like to compare this to what we have already seen above, when
we had
,
,
,
,
, and
.
Proof We shall use the same idea as last time - but without drawing
a set of axes in
dimensions!
Firstly, let's do the uniqueness part. Suppose that we have two solutions,
and
. Then
(mod
), and
(mod
),
and ..., and
(mod
), so
and
differ by a
multiple of
. Also, if
is a solution and
is an
integer, then
is also a solution. So the
solutions all differ by multiples of
, as we wanted.
Now let's try to prove that there is a solution!
Using the same ideas as before, let's suppose that we can find numbers
,
, ..., and
in such a way that
corresponds to
the point with
co-ordinate equal to
, and the other
co-ordinates all
. Then
is a
solution to the congruences as required. For example, mod
none of the
, ...,
parts contribute (as they are all congruent to
(mod
)), so
(mod
) (as
(mod
)), and similarly for
,
, ..., and
.
We now just need to find
,
, ..., and
with the given
properties. For example, we need
such that
We shall need
to be divisible by all of
,
, ... and
. So we can write it as
for some
integer
. Now we need
(mod
). It is a result of number theory that (because
shares
no factors greater than
with
,
, ..., or
) we may
solve this. You can find an explanation of this in the NRICH article
Modular
Arithmetic, but if you are willing to take the result on trust for now then
you can save the article for later! We can find
,
, ... and
in the same way, and so we have the required numbers.
Since we can find
,
, ... and
, we can find
that solves the congruences, and,
since we can find our solution we can, by our earlier work on uniqueness,
find all the integer solutions, and so
our proof is complete.
In fact, we can be a bit more general than this. For example, it is
sufficient for
,
, ... and
to be pairwise coprime (no
two have a common factor greater than
) rather than just prime, and
the proof proceeds in the same way.
You might like to look at two related problems on the NRICH site:
Remainders and
One O Five.