Chinese Remainder Theorem/General Result

Theorem
Let $b_1, b_2, \ldots, b_r \in \Z$.

Let $n_1, n_2, \ldots, n_r$ be pairwise coprime positive integers.

Let $\ds N = \prod_{i \mathop = 1}^r n_i$.

Then the system of linear congruences:

has a simultaneous solution which is unique modulo $N$.

Existence
Let $N_k = \dfrac N {n_k}$ for $k = 1, 2, \ldots, r$.

From Integer Coprime to all Factors is Coprime to Whole:


 * $\gcd \set {N_k, n_k} = \gcd \set {n_1 n_2 \cdots n_{k - 1} n_{k + 1} \cdots n_r, n_k} = 1$

And for each $k = 1, 2, 3, \ldots, r$:

From Solution of Linear Congruence, the linear congruence


 * $N_k x \equiv 1 \pmod {n_k}$

has a unique solution modulo $n_k$.

Let this solution be $x_k$.

That is:


 * $N_k x_k \equiv 1 \pmod {n_k}$

Let $\ds x_0 = \sum_{i \mathop = 1}^r b_i N_i x_i$.

Then for each $k = 1, 2, 3, \ldots, r$:

Thus $x_0$ is a simultaneous solution.

Uniqueness
Suppose $x'$ is a second solution of the system.

That is:


 * $x_0 \equiv x' \equiv b_k \pmod {n_k}$

for each $k = 1, 2, \ldots, r$.

By definition of congruence:


 * $n_k \divides x' - x_0$

for each $k = 1, 2, \ldots, r$.

From All Factors Divide Integer then Whole Divides Integer:


 * $N \divides x' - x_0$

By definition of congruence:


 * $x' \equiv x_0 \pmod {N}$

Thus the simultaneous solution is unique modulo $N$.

Also see

 * Chinese Remainder Theorem (Commutative Algebra)