1.2.7. The Chinese Remainder Theorem

This section is based on parts of [BUR11, Sec. 4.4, Sec. 7.3].

Theorem 1.2.7.1.

Let k≥1{k\geq 1} be an integer and n1,…,nkn_{1},\ldots,n_{k} positive integers such that gcd⁡(ni,nj)=1{\gcd(n_{i},n_{j})=1} for i≠j{i\neq j}. For integers a1,…,aka_{1},\ldots,a_{k}, we consider the system of linear congruences

x\displaystyle x ≡a1(modn1)\displaystyle\equiv a_{1}\pmod{n_{1}}
x\displaystyle x ≡a2(modn2)\displaystyle\equiv a_{2}\pmod{n_{2}}
⋮\displaystyle\vdots
x\displaystyle x ≡ak(modnk).\displaystyle\equiv a_{k}\pmod{n_{k}}.

Then this system has a solution and this solution is unique modulo n=n1⁢⋯⁢nk{n=n_{1}\cdots n_{k}}.

Proof.

We first prove that the system of linear congruences admits a solution. For this, for each 1≤i≤k{1\leq i\leq k}, we construct a solution xix_{i} to the iith congruence x≡ai(modni){x\equiv a_{i}\pmod{n_{i}}} such that xi≡0(modnj){x_{i}\equiv 0{\pmod{n_{j}}}} for j≠i{j\neq i}. The integer

x0≔∑i=1kxix_{0}\coloneqq\sum_{i=1}^{k}x_{i}

is then a solution of the system. Notice first that the integer aia_{i} is certainly a solution to the iith congruence x≡ai(modni){x\equiv a_{i}\pmod{n_{i}}}, but it need not be divisible by njn_{j} for j≠i{j\neq i}. We modify the tautological solution aia_{i} as follows: consider the auxiliary integer bi≔n/ni{b_{i}\coloneqq n/n_{i}} and notice that

bi≡0(modnj),j≠i.b_{i}\equiv 0{\pmod{n_{j}}},\qquad j\neq i.

Moreover, since bi=∏j≠inj{b_{i}=\prod_{j\neq i}n_{j}} and the moduli nin_{i} are pairwise coprime, we have gcd⁡(bi,ni)=1{\gcd(b_{i},n_{i})=1}. Euler’s Theorem (Theorem 1.2.6.2) then yields the congruence

biφ⁢(ni)≡1(modni),b_{i}^{\varphi(n_{i})}\equiv 1\pmod{n_{i}},

and hence, by Proposition 1.2.1.6(4),

ai⁢biφ⁢(ni)≡ai(modni).a_{i}b_{i}^{\varphi(n_{i})}\equiv a_{i}\pmod{n_{i}}.

The integer

xi≔ai⁢biφ⁢(ni)x_{i}\coloneqq a_{i}b_{i}^{\varphi(n_{i})}

thus has the required properties, which finishes the proof of existence.

We now show that the solution is unique modulo n=n1⁢⋯⁢nk{n=n_{1}\cdots n_{k}}. Let y0∈ℤ{y_{0}\in\mathbb{Z}} be a solution to the system of congruences, that is,

y0≡ai(modni),1≤i≤k.y_{0}\equiv a_{i}{\pmod{n_{i}}},\qquad 1\leq i\leq k.

Then x0≡y0(modni){x_{0}\equiv y_{0}{\pmod{n_{i}}}} for each 1≤i≤k{1\leq i\leq k}. Since the moduli nin_{i} are pairwise coprime, a straightforward induction using Lemma 1.2.6.1 shows that x0≡y0(modn){x_{0}\equiv y_{0}{\pmod{n}}}. This finishes the proof. ∎

Remark 1.2.7.2.

Theorem 1.2.7.1 can also be proven using Bézout’s Identity (Theorem 1.1.3.7) and its corollaries, for instance. This yields alternative and typically more efficient methods for solving the corresponding linear systems. See the model solutions to the companion exercises.

We explain how to use the proof of the Chinese Remainder Theorem (Theorem 1.2.7.1) to solve a suitable system of linear congruences.

Example 1.2.7.3.

Consider the system of linear congruences

x\displaystyle x ≡1(mod3)\displaystyle\equiv 1{\pmod{3}}
x\displaystyle x ≡3(mod5)\displaystyle\equiv 3{\pmod{5}}
x\displaystyle x ≡1(mod7).\displaystyle\equiv 1{\pmod{7}}.

Since the moduli are distinct primes, they are pairwise coprime. We have

n=105=3⋅5⋅7,\displaystyle n=105=3\cdot 5\cdot 7,
b1=35,b2=21andb3=15.\displaystyle b_{1}=35,\quad b_{2}=21\quad\text{and}\quad b_{3}=15.

As shown in the proof of the Chinese Remainder Theorem (Theorem 1.2.7.1),

x0=1⋅352+3⋅214+1⋅156=11⁢975⁢293x_{0}=1\cdot 35^{2}+3\cdot 21^{4}+1\cdot 15^{6}=11~{}975~{}293

is a solution to the system of congruences. Here we use that φ⁢(3)=2{\varphi(3)=2}, φ⁢(5)=4{\varphi(5)=4} and φ⁢(7)=6{\varphi(7)=6}. The integer x0x_{0}, however, is very large. Since we are only interested in the solution of the system modulo 105105, we may reduce the powers of the auxiliary integers bib_{i} by observing the following equalities:

b12\displaystyle b_{1}^{2} =352=1225=11⋅105+70\displaystyle=35^{2}=1225=11\cdot 105+70
b22\displaystyle b_{2}^{2} =212=441=4⋅105+21\displaystyle=21^{2}=441=4\cdot 105+21
b32\displaystyle b_{3}^{2} =152=225=2⋅105+15.\displaystyle=15^{2}=225=2\cdot 105+15.

Hence,

352≡70(mod105),212≡21(mod105),and152≡15(mod105).35^{2}\equiv 70{\pmod{105}},\quad 21^{2}\equiv 21{\pmod{105}},\quad\text{and}% \quad 15^{2}\equiv 15{\pmod{105}}.

Consequently,

214≡21(mod105)and156≡15(mod105).21^{4}\equiv 21{\pmod{105}}\qquad\text{and}\qquad 15^{6}\equiv 15{\pmod{105}}.

Thus, we may replace the solution x0x_{0} by the integer

x0′=1⋅70+3⋅21+1⋅15=148,x_{0}^{\prime}=1\cdot 70+3\cdot 21+1\cdot 15=148,

since x0≡x0′(mod105){x_{0}\equiv x_{0}^{\prime}{\pmod{105}}}. Finally, 148=1⋅105+43{148=1\cdot 105+43} and hence we may replace x0′x_{0}^{\prime} by the integer

x0′′=43,x_{0}^{\prime\prime}=43,

which is also a solution to the original system of congruences since

x0≡43(mod105).x_{0}\equiv 43{\pmod{105}}.

Indeed,

43=14⋅3+1,43=8⋅5+3,and43=6⋅7+1.43=14\cdot 3+1,\quad 43=8\cdot 5+3,\quad\text{and}\quad 43=6\cdot 7+1.

End of Lecture 9