The Chinese Remainder Theorem (CRT) solves systems of simultaneous congruences. "Find a number that leaves remainder 2 when divided by 3, remainder 3 when divided by 5, and remainder 2 when divided by 7." This is the classic Sun Zi problem from ancient China. CRT tells us when solutions exist and how to find them.
If $ m_1, m_2, ..., m_k $ are pairwise coprime (gcd of any two is 1), then for any integers $ a_1, a_2, ..., a_k $, the system:
\[ \begin{cases} x \equiv a_1 \pmod{m_1} \\ x \equiv a_2 \pmod{m_2} \\ \quad \vdots \\ x \equiv a_k \pmod{m_k} \end{cases} \]
has a unique solution modulo $ M = m_1 m_2 ... m_k $.
Two key takeaways:
Let $ M = m_1 m_2 ... m_k $ and $ M_i = M / m_i $ (product of all moduli except $m_i$).
Since moduli are pairwise coprime, gcd($M_i, m_i$) = 1, so $M_i$ has an inverse mod $m_i$. Call it $y_i$.
Then the solution is:
\[ x \equiv a_1 M_1 y_1 + a_2 M_2 y_2 + ... + a_k M_k y_k \pmod{M} \]
Why it works: each term $a_i M_i y_i$ is congruent to $a_i$ mod $m_i$ (since $M_i y_i \equiv 1$ mod $m_i$), and congruent to 0 mod every other $m_j$ (since $M_i$ contains $m_j$ as a factor).
Often easier for small systems. Solve two congruences at a time:
This works even when moduli aren't coprime (as long as a solution exists).
When moduli aren't pairwise coprime, a solution exists iff for every pair i, j:
\[ a_i \equiv a_j \pmod{\gcd(m_i, m_j)} \]
If the congruences are consistent on the overlapping parts, there's a unique solution mod \(lcm(m_{1}, m_{2},\) ..., m_k).
\(If inconsistent (e.g., x \\equiv 1 mod 2 and x \\equiv 2 mod 4), no solution exists.\)
CRT means $ \mathbb{Z}/M\mathbb{Z} \cong \mathbb{Z}/m_1\mathbb{Z} \times ... \times \mathbb{Z}/m_k\mathbb{Z} $ \(when the m_{i} are pairwise coprime.\)
\(In plain language: working mod M is equivalent to working mod each m_{i} separately, component by component.\)
This is why multiplicative functions factor over prime powers β because the ring splits into independent pieces.
3, 5, 7 are pairwise coprime. Use successive substitution.
Step 1: From first congruence: x = 2 + 3t
Step 2: \(Substitute into second: 2 + 3t \\equiv 3 (mod 5)\)
\(3t \\equiv 1 (mod 5)\)
\(Inverse of 3 mod 5 is 2 (since 3 \\times 2 = 6 \\equiv 1 mod 5)\)
\(t \\equiv 2 \\times 1 = 2 (mod 5)\)
t = 2 + 5s
Step 3: x = 2 + 3(2 + 5s) = 2 + 6 + 15s = 8 + 15s
\(Combined so far: x \\equiv 8 (mod 15)\)
Step 4: \(Substitute into third: 8 + 15s \\equiv 2 (mod 7)\)
8 mod 7 = 1, 15 mod 7 = 1
\(1 + s \\equiv 2 (mod 7)\)
\(s \\equiv 1 (mod 7)\)
s = 1 + 7u
Step 5: x = 8 + 15(1 + 7u) = 8 + 15 + 105u = 23 + 105u
Smallest positive: x = 23
Verify: 23 mod 3 = 2 β, 23 mod 5 = 3 β, 23 mod 7 = 2 β
Answer: 23
\(m_{1} = 4, m_{2}\) = 5. gcd(4,5) = 1. CRT applies.
Step 1: \(M = 4 \\times 5 = 20\)
Step 2: \(M_{1} = M/m_{1} = 20/4 = 5, M_{2} = M/m_{2}\) = 20/5 = 4
Step 3: Find inverses \(y_{1} and y_{2}.\)
\(y_{1}\) = inverse of \(M_{1} = 5 mod m_{1}\) = 4
5 mod 4 = 1, inverse of 1 mod 4 is 1. So \(y_{1}\) = 1.
\(y_{2}\) = inverse of \(M_{2} = 4 mod m_{2}\) = 5
\(4 \\times 4 = 16 \\equiv 1 mod 5. So y_{2} = 4.\)
Step 4: Apply formula.
\[ x \equiv a_1 M_1 y_1 + a_2 M_2 y_2 \pmod{20} \]
\(x \\equiv 1 \\times 5 \\times 1 + 2 \\times 4 \\times 4 (mod 20)\)
\(x \\equiv 5 + 32 = 37 (mod 20)\)
37 mod 20 = 17
Step 5: Smallest positive x = 17
Verify: 17 mod 4 = 1 β, 17 mod 5 = 2 β
Answer: 17
Moduli 4 and 6 are NOT coprime. gcd(4, 6) = 2.
Consistency check: \(We need a_{1} \\equiv a_{2} mod gcd(m_{1}, m_{2})\)
\(Check: is 1 \\equiv 2 (mod 2)\)?
1 mod 2 = 1
2 mod 2 = 0
\(1 \\neq 0.\) Inconsistent!
Intuition: \(x \\equiv 1 mod 4 means x is odd (1, 5, 9, 13, ...).\)
\(x \\equiv 2 mod 6 means x is even (2, 8, 14, 20, ...).\)
A number can't be both odd and even. No solution exists.
Answer: 0 (no solution)
\(Note: if the second congruence were x \\equiv 3 mod 6, then 1 \\equiv 3 mod 2 (both odd), so it would be consistent\) and we could find a solution.