Skip to main content
AMC 12 only

Chinese Remainder Theorem

A system of remainder conditions with coprime moduli always has exactly one solution in a predictable range — CRT tells you how to find it.

The Chinese Remainder Theorem (CRT) says that a system of congruences with pairwise coprime moduli always has a solution, and that solution is unique modulo the product of the moduli:

xr1(modm1),xr2(modm2),x \equiv r_1 \pmod{m_1}, \quad x \equiv r_2 \pmod{m_2}, \quad \ldots

has a unique solution modulo m1m2m_1 \cdot m_2 \cdots (given the mim_i are pairwise coprime).

The practical method

You rarely need the general CRT formula on a contest — it’s usually faster to solve incrementally: take the first congruence, and among the numbers satisfying it, substitute into the second congruence to narrow down further, repeating until all conditions are satisfied.

Worked example

Problem: Find the smallest positive integer xx such thatx2(mod3)x \equiv 2 \pmod 3 and x3(mod5)x \equiv 3 \pmod 5.

Solution: Numbers satisfying x2(mod3)x \equiv 2 \pmod 3: 2,5,8,11,14,2, 5, 8, 11, 14, \ldots(each is 3k+23k+2). Test these against the second condition x3(mod5)x \equiv 3 \pmod 5:

2mod5=2 ×,5mod5=0 ×,8mod5=3 2\bmod5=2 \ \times,\quad 5\bmod5=0 \ \times,\quad 8\bmod5=3\ \checkmark

So x=8x=8 works. By CRT, since gcd(3,5)=1\gcd(3,5)=1, the full solution set isx8(mod15)x \equiv 8 \pmod{15} — every 15th integer after 8 also works.

Practice problems

1.Find the smallest positive integer with x1(mod4)x\equiv1\pmod4 and x2(mod5)x\equiv2\pmod5.

2.Given x2(mod3)x\equiv2\pmod3 and x4(mod7)x\equiv4\pmod7, find the general solution modulo 2121.

3.Find the smallest positive integer satisfying x1(mod2)x\equiv1\pmod2, x2(mod3)x\equiv2\pmod3, and x3(mod5)x\equiv3\pmod5.

4.Why does CRT require the moduli to be pairwise coprime?