# Chinese Remainder Theorem

The Chinese Remainder Theorem is a number theoretic result. It is one of the only theorems named for an oriental person or place, due to the closed development of mathematics in the western world.

## Theorem

Formally stated, the Chinese Remainder Theorem is as follows:

Let $m$ be relatively prime to $n$. Then each residue class mod $mn$ is equal to the intersection of a unique residue class mod $m$ and a unique residue class mod $n$, and the intersection of each residue class mod $m$ with a residue class mod $n$ is a residue class mod $mn$.

Simply stated:

Suppose you wish to find the least number $x$ which leaves a remainder of: \begin{aligned} &y_{1} \text{ when divided by } &d_{1}\\ &y_{2} \text{ when divided by } &d_{2}\\ &\vdots &\vdots\\ &y_{n} \text{ when divided by } & d_{n}\\ \end{aligned}

such that $d_{1}$ , $d_{2}$ , ... $d_{n}$ are all relatively prime. Let $M = d_{1}d_{2} \cdots d_{n}$, and $b_{i} = \frac{M}{d_{i}}$. Now if the numbers $a_{i}$ satisfy: $a_{i}b_{i} \equiv 1 \pmod {d_{i}}$

for every $1 \leq i \leq n$, then a solution for $x$ is: $x = \sum_{i=1}^n a_{i}b_{i}y_{i} \pmod M$

## Proof

If $a \equiv b \pmod{mn}$, then $a$ and $b$ differ by a multiple of $mn$, so $a \equiv b \pmod{m}$ and $a \equiv b \pmod{n}$. This is the first part of the theorem. The converse follows because $a$ and $b$ must differ by a multiple of $m$ and $n$, and $\mbox{lcm}(m,n) = mn$. This is the second part of the theorem.

## Applicability

Much like the Fundamental Theorem of Arithmetic, many people seem to take this theorem for granted before they consciously turn their attention to it. Its ubiquity derives from the fact that many results can be easily proven mod (a power of a prime), and can then be generalized to mod $m$ using the Chinese Remainder Theorem. For instance, Fermat's Little Theorem may be generalized to the Fermat-Euler Theorem in this manner.

General Case: the proof of the general case follows by induction to the above result (k-1) times.

## Extended version of the theorem

Suppose one tried to divide a group of fish into $2$, $3$ and $4$ parts instead and found $1$, $1$ and $2$ fish left over, respectively. Any number with remainder $1$ mod $2$ must be odd and any number with remainder $2$ mod $4$ must be even. Thus, the number of objects must be odd and even simultaneously, which is a contradiction. Thus, there must be restrictions on the numbers $a_1,\dots,a_n$ to ensure that at least one solution exists. It follows that:

The solution exists if and only if $a_i\equiv a_j\mod \gcd(m_i,m_j)$ for all $i,j$ where $\gcd$ stands for the greatest common divisor. Moreover, in the case when the problem is solvable, any two solutions differ by some common multiple of $m_1,\ldots,m_n$. (the extended version).