Skip to main content

Section 4.5 The Chinese Remainder Theorem

The Chinese Remainder Theorem is a result in number theory about solving simultaneous systems of several linear congruences. In this section we explore its origins and give methods to solve these systems.

Exploration 4.5.1. Sun Zi's Problem.

Sun Zi (ๅญ™ๅญ) was a Chinese mathematician who in his text Sunzi Suanjingใ€Šๅญ™ๅญ็ฎ—็ปใ€‹ (3rd to 5th century AD) is said to have written the earliest known reference to systems of linear congruences. In it he writes:

โ€˜ไปŠๆœ‰็‰ฉ๏ผŒไธ็Ÿฅๅ…ถๆ•ฐใ€‚ไธ‰ใ€ไธ‰ๆ•ฐไน‹๏ผŒๅ‰ฉไบŒ๏ผ›ไบ”ใ€ไบ”ๆ•ฐไน‹๏ผŒๅ‰ฉไธ‰๏ผ›ไธƒใ€ไธƒๆ•ฐไน‹๏ผŒๅ‰ฉไบŒใ€‚้—ฎ็‰ฉๅ‡ ไฝ•๏ผŸโ€™

โ€•ๅญ™ๅญใ€‚ใ€Šๅญ™ๅญ็ฎ—็ปใ€‹ใ€‚

โ€˜A number is repeatedly divided by 3, the remainder is 2; divided by 5, the remainder is 3; and by 7, the remainder is 2. What will the number be?โ€™

โ€•Sun Zi, Sunzi Suanjing, Vol. 3, Problem 26 (as cited in [5])

We follow Sun Zi's method of solving this system.

(a)

The first condition in Sun Zi's problem can be written as

xโ‰ก2 (mod 3).

Write all three conditions as a system of linear congruences.

(b)

Since the integers 3, 5, and 7 are pairwise relatively prime, then 35โˆ’1 (mod 3) exists. Compute this quantity.

Similarly, compute 21โˆ’1 (mod 5) and 15โˆ’1 (mod 7).

(c)

Explain why each of the following congruences hold:

{2โ‹…35โˆ’1โ‹…35โ‰ก2 (mod 3)3โ‹…21โˆ’1โ‹…21โ‰ก3 (mod 5)2โ‹…15โˆ’1โ‹…15โ‰ก2 (mod 7).
(d)

Explain why we can conclude that

xโ‰ก2โ‹…35โˆ’1โ‹…35+3โ‹…21โˆ’1โ‹…21+2โ‹…15โˆ’1โ‹…15 (mod 105)

is a solution to the original system of congruences, and using your answers from (b) simplify this expression to get an answer modulo 105.

Finally, verify that the answer satisfies all three conditions.

The method outlined in Exploration 4.5.1 actually works for the general case, as long as the moduli in the system are pairwise relatively prime. Before stating our main theorems let's look at a smaller examples, one with only two congruences.

Find a natural number \(x\) that leaves a remainder of 3 when divided by 5, and a remainder of 1 when divided by 7.

Hint

What are the numbers that satisfy the first condition? Among these, find one satisfying the second as well.

The solution to Checkpoint 4.5.1 did not use the same method as Exploration 4.5.1 and instead just relied on listing numbers. This won't be efficient for larger systems, so let's try to proceed more systematically.

Theorem 4.5.2 speaks to the existence and uniqueness of a solution to the given system. Try proving it yourself in the next two exercises!

Prove that \(x \equiv atm_2 + bsm_1 \Mod{m_1m_2}\) satisfies both congruences in the given system.

Prove that \(x \equiv atm_2 + bsm_1 \Mod{m_1m_2}\) is the only solution to the given system modulo \(m_1m_2\text{.}\)

Finally we state a method for a general system of congruences.

Solve the system of congruences

\begin{equation*} \begin{cases} x \equiv 4 \Mod{5} \\ x \equiv 5 \Mod{6} \\ x \equiv 6 \Mod{7} \end{cases} \end{equation*}

using the method in Theorem 4.5.6.

One consequence of Theorem 4.5.6 is that there is a bijection between n-tuples

(a1,a2,โ€ฆ,an)โˆˆZm1ร—Zm2ร—โ‹ฏร—Zmn

and congruence classes modulo M=โˆi=1nmi, as long as the moduli mi are pairwise relatively prime.

That is, any number in {0,1,โ€ฆ,M} has a unique representation as a collection of remainders ai for each modulus mi.

Let \(x \equiv 1 \Mod{2}\) and \(x \equiv 2 \Mod{5}\text{.}\) Then Theorem 4.5.6 tells us that the solution \(x \equiv 7 \Mod{10}\) is unique.

In fact for any pair of remainders modulo 2 and 5, we get a unique congruence class modulo 10 as a solution to the system

\begin{equation*} \begin{cases} x \equiv a_1 \Mod{2} \\ x \equiv a_2 \Mod{5}\end{cases} \end{equation*}

Verify that we have a bijection between \(\mathbb{Z}_2 \times \mathbb{Z}_5\) and \(\mathbb{Z}_{10}\text{:}\)

\(\mathbb{Z}_2 \times \mathbb{Z}_5\) \(\mathbb{Z}_{10}\)
\((0,0)\) \(0\)
\((0,1)\) \(6\)
\((0,2)\) \(2\)
\((0,3)\) \(8\)
\((0,4)\) \(4\)
\(\mathbb{Z}_2 \times \mathbb{Z}_5\) \(\mathbb{Z}_{10}\)
\((1,0)\) \(5\)
\((1,1)\) \(1\)
\((1,2)\) \(7\)
\((1,3)\) \(3\)
\((1,4)\) \(9\)

Verify that 19 is a solution to the system

\begin{equation*} \begin{cases} x \equiv 1 \Mod{3} \\ x \equiv 5 \Mod{7}\end{cases} \end{equation*}

Then, use this fact to compute \(19^{20} \mmod{21}\text{.}\)

Hint

Instead of computing large powers of 19, compute large powers of 1 and 5 (with respective moduli) then use Theorem 4.5.2.

Solutions Solutions to Selected Checkpoints

Checkpoint 4.5.1. Two Congruences.