You are on page 1of 10

Chinese Remainder

Theorem
An example:
Find a number x such that have remainders of
1 when divided by 3, 2 when divided by 5 and
3 when divided by 7. i.e.
x =1 mod 3
x = 2 mod 5
x = 3 mod 7

Introduction
used to speed up modulo computations
Integers can be represented by their residues
modulo a set of pairwise relatively prime
moduli.
E.g. In Z
10
, integer 8 can be represented by the
residues of the 2 relatively prime factors of 10
(2&5) as a tuple (0, 3)
Chinese Remainder Theorem (CRT)
Let m
1
, m
2
, , m
k
be pairwise relatively prime
integers. That is, gcd(m
i
, m
j
) = 1 for 1si<j sk.
Let a
i
eZ
mi
for 1si sk and set M=m
1
m
2
m
k
.
Then there exists a unique A eZ
m
such that
Aa
i
mod m
i
for i = 1k.
A can be computed as:


Where for 1sisk.
1
( ) mod
k
i i
i
A a c M
=


1
( mod ) & /
i i i i i i
c M M m M M m

= =
Proof:
A is a solution
Since

for any j=I
Therefore,


1 2 1 1
... ...
i i i k
M m m m m m
+
=
1
1mod
( mod )
0mod
i
i i i i
j
m
c M M m
m


= =

1
1 1 2 2
( ) mod
...
mod
k
i i
i
k k
i i
A a c m
c a c a c a r m
a m
=
=

= + + + +
=
Proof (cont.):
A is unique in Z
m
If A is not the unique answer, there must exist
another answer A a
i
mod m
i
in Z
m
.
Then A A mod m
i
A-A = r
1
*m
1
= r
2
*m
2
= r
k
*m
k
r
i
|m
j
where i=j (since m
i
s are relatively prime)
r
i
*m
i
= r
i
*m
1
*m
2
**m
k
= r
i
*m
m|A-A
A A mod m, proving uniqueness.
Properties:
(A+B) mod M
((a
1
+ b
1
) mod m
1
, , (a
k
+ b
k
)mod m
k
)
(A-B) mod M
((a
1
- b
1
) mod m
1
, , (a
k
- b
k
)mod m
k
)
(AB) mod M
((a
1
b
1
) mod m
1
, , (a
k
b
k
)mod m
k
)
Example 1:
Represent 973 in Z
1813
as a k-tuple:
Answer:
M = 1813 = 37 * 49 m
1
= 37 & m
2
= 49
A = 973
A = (A mod m
1
, A mod m
2
) = (11, 42)
Example 2:
Give x = 11 mod 37 & x = 42 mod 49, find x.
Answer:


since M
1
= 49 & M
1
-1
mod m
1
= 34 and M
2
= 37 &
M
2
-1
mod m
2
= 4


2
1 1
1 1 1 2 2 2
1
( ) mod mod
i i
i
x a c M a M M a M M M

=
= = +

11 49 34 42 37 4mod
24542mod1813
973
x M = +
=
=
Exercises:
Question 1:
Represent 75 in Z
77
using Chinese Remainder
Theorem.
Question 2:
Given x = 6 mod 13 and x = 2 mod 17, find x.

You might also like