next up previous
Next: Multiplicative Functions Up: Lecture 6: Congruences, Part Previous: Wilson's Theorem

The Chinese Remainder Theorem

Sun Tsu Suan-Ching (4th century AD):
There are certain things whose number is unknown. Repeatedly divided by 3, the remainder is 2; by 5 the remainder is 3; and by 7 the remainder is 2. What will be the number?
In modern notation, Sun is asking us to solve the following system of equations:

$\displaystyle x$ $\displaystyle \equiv 2 \pmod{3}$    
$\displaystyle x$ $\displaystyle \equiv 3 \pmod{5}$    
$\displaystyle x$ $\displaystyle \equiv 2 \pmod{7}$    

The Chinese Remainder Theorem asserts that a solution to Sun's question exists, and the proof gives a method to find a solution.

Theorem 2.1 (The Chinese Remainder Theorem)   Let $ a, b\in\mathbb{Z}$ and $ n,m\in\mathbb{N}$ such that $ \gcd(n,m)=1$. Then there exists $ x\in\mathbb{Z}$ such that

$\displaystyle x$ $\displaystyle \equiv a\pmod{m}$    
$\displaystyle x$ $\displaystyle \equiv b\pmod{n}$    

Proof. The equation

$\displaystyle tm \equiv b-a\pmod{n}
$

has a solution $ t$ since $ \gcd(m,n)=1$. Set $ x=a+tm$. We next verify that $ x$ is a solution to the two equations. Then

$\displaystyle x \equiv a + (b-a) \equiv b \pmod{n},
$

and

$\displaystyle x = a+tm \equiv a\pmod{m}.
$

$ \qedsymbol$

Now we can solve Sun's problem:

$\displaystyle x$ $\displaystyle \equiv 2 \pmod{3}$    
$\displaystyle x$ $\displaystyle \equiv 3 \pmod{5}$    
$\displaystyle x$ $\displaystyle \equiv 2 \pmod{7}.$    

First, we use the theorem to find a solution to the pair of equations

$\displaystyle x$ $\displaystyle \equiv 2 \pmod{3}$    
$\displaystyle x$ $\displaystyle \equiv 3 \pmod{5}.$    

Set $ a=2$, $ b=3$, $ m=3$, $ n=5$. Step 1 is to find a solution to $ t\cdot 3 \equiv 3-2\pmod{5}$. A solution is $ t=2$. Then $ x=a+tm=2+2\cdot 3 = 8$. Since any $ x'$ with $ x'\equiv x\pmod{15}$ is also a solution to those two equations, we can solve all three equations by finding a solution to the pair of equations

$\displaystyle x$ $\displaystyle \equiv 8 \pmod{15}$    
$\displaystyle x$ $\displaystyle \equiv 2 \pmod{7}.$    

Again, we find a solution to $ t\cdot 15 \equiv 2-8\pmod{7}$. A solution is $ t = 1$, so

$\displaystyle x=a+tm=8+15=23.$

Note that there are other solutions. Any $ x'\equiv x\pmod{3\cdot 5\cdot 7}$ is also a solution; e.g., $ 23+3\cdot 5\cdot 7 = 128$.

We can also solve Sun's problem in PARI:

? chinese(Mod(2,3),Mod(3,5))
%13 = Mod(8, 15)
? chinese(Mod(8,15),Mod(2,7))
%14 = Mod(23, 105)


next up previous
Next: Multiplicative Functions Up: Lecture 6: Congruences, Part Previous: Wilson's Theorem
William A Stein 2001-09-23