Professional Documents
Culture Documents
Chinese Remainder Theorem
Chinese Remainder Theorem
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 m
odulo a set of pairwise relatively prime moduli
.
E.g. In Z10, 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 m1, m2, …, mk be pairwise relatively prime
integers. That is, gcd(mi, mj) = 1 for 1i<j k.
Let aiZmi for 1i k and set M=m1m2…mk. Th
en there exists a unique A Zm such that Aai
mod mi for i = 1…k.
A can be computed as:
k
A ( ai ci ) mod M
i 1
1
c
Where i M i ( M mod mi ) & M i M / mi
fori 1ik.
Proof:
A is a solution
Since M i m1 m2 ... mi 1 mi 1... mk
1 1mod mi
ci M i ( M mod mi )
i
0 mod m j for any jI
k
Therefore, A ( ai ci ) mod m
i 1
c1a1 c2 a2 ... ck ak r m
ai mod mi
Proof (cont.):
A is unique in Zm
IfA is not the unique answer, there must exist anot
her answer A’ ai mod mi in Zm.
Then A A’ mod mi
A-A’ = r1*m1 = r2*m2 = …rk*mk
ri|mj where ij (since mi’s are relatively prime)
ri*mi = ri’*m1*m2*…*mk = ri’*m
m|A-A’
A A’ mod m, proving uniqueness.
Properties:
(A+B) mod M
((a1 + b1) mod m1, …, (ak + bk)mod mk)
(A-B) mod M
((a1 - b1) mod m1, …, (ak - bk)mod mk)
(AB) mod M
((a1 b1) mod m1, …, (ak bk)mod mk)
Example 1:
Represent 973 in Z1813 as a k-tuple:
Answer:
M = 1813 = 37 * 49 m1 = 37 & m2 = 49
A = 973
A = (A mod m1, A mod m2) = (11, 42)
Example 2:
Give x = 11 mod 37 & x = 42 mod 49, find x.
Answer:
2
1 1
x ( ai ci ) mod M a1M 1M 1 a2 M 2 M mod M
2
i 1
since M1 = 49 & M1-1 mod m1 = 34 and M2 = 37 &
M2-1 mod m2 = 4
x 11 49 34 42 37 4 mod M
24542 mod1813
973
Exercises:
Question 1:
Represent 75 in Z77 using Chinese Remainder
Theorem.
Question 2: