PrevNext

Overview

The Chinese Remainder Theorem (CRT) states that if you know the remainders of a number xx when divided by several pairwise coprime integers, you can uniquely determine the remainder of xx when divided by the product of those integers.

Structurally, CRT establishes a bijection (a perfect one-to-one correspondence) between a number modulo M=m1m2⋯mkM = m_1m_2\cdots m_k and a tuple of its remainders modulo each mim_i. This means that any operation you do on the large modulus MM can be broken down, computed on the smaller moduli mim_i independently, and then stitched back together.

Visualizing the Theorem: The Number Line Alignment

To see why this works, imagine overlapping number lines. Suppose we want to find a number xx that satisfies:

  • x≡2(mod3)x \equiv 2 \pmod{3}
  • x≡3(mod5)x \equiv 3 \pmod{5}

If we list the valid non-negative numbers for each condition, we are looking for the points where the two sequences "align" or intersect:

ConditionValid Solutions for xx
x≡2(mod3)x \equiv 2 \pmod{3}2, 5, 8, 11, 14, 17, 20, 23, 26, 29
x≡3(mod5)x \equiv 3 \pmod{5}3, 8, 13, 18, 23, 28, 33

The sequences overlap at 8 and 23. Notice that the distance between these overlapping solutions is exactly 1515, which is 3×53 \times 5. The Chinese Remainder Theorem formalizes this exact phenomenon: the intersection of these periodic sequences will always form a new, perfectly regular sequence modulo the product of their coprime bases!

Key Ideas

  • The Core Theorem: If m1,m2,…,mkm_1, m_2, \ldots, m_k are pairwise coprime positive integers (gcd⁡(mi,mj)=1\gcd(m_i, m_j) = 1 for i≠ji \neq j), the system x≡ai(modmi)x \equiv a_i \pmod{m_i} has a unique solution modulo M=m1m2⋯mkM = m_1 m_2 \cdots m_k.
  • Constructive Substitution: To solve manually, write the congruence with the largest modulus as an algebraic equation (e.g., x=m1⋅k+a1x = m_1 \cdot k + a_1), substitute it into the next congruence, and solve for kk.
  • The Formulaic Approach (Using Inverses): For a system of two congruences x≡a(modm)x \equiv a \pmod{m} and x≡b(modn)x \equiv b \pmod{n}, you can use the Extended Euclidean Algorithm to find u,vu, v such that mu+nv=1mu + nv = 1. The solution is then x≡a(nv)+b(mu)(modmn)x \equiv a(nv) + b(mu) \pmod{mn}.

Worked Examples

Example 1: Standard System Reconstruction

Find the smallest positive integer xx that satisfies:

x≡2(mod3)x≡3(mod5)x≡2(mod7)x \equiv 2 \pmod{3} \\ x \equiv 3 \pmod{5} \\ x \equiv 2 \pmod{7}

Solution: First, look for shortcuts. Notice that x≡2(mod3)x \equiv 2 \pmod{3} and x≡2(mod7)x \equiv 2 \pmod{7}. Because 3 and 7 are coprime, we can directly combine these into a single congruence: x≡2(mod21)x \equiv 2 \pmod{21}.

Now we have a two-congruence system:

x≡2(mod21)x≡3(mod5)x \equiv 2 \pmod{21} \\ x \equiv 3 \pmod{5}

Convert the first congruence into an equation: x=21k+2x = 21k + 2 for some integer kk. Substitute this into the second congruence:

21k+2≡3(mod5)21k + 2 \equiv 3 \pmod{5}

Reduce 21(mod5)21 \pmod{5} to 11:

k+2≡3(mod5)  ⟹  k≡1(mod5)k + 2 \equiv 3 \pmod{5} \implies k \equiv 1 \pmod{5}

Write kk as an equation: k=5j+1k = 5j + 1. Substitute back into xx:

x=21(5j+1)+2=105j+23x = 21(5j + 1) + 2 = 105j + 23

Thus, x≡23(mod105)x \equiv 23 \pmod{105}. The smallest positive integer is 2323.

Example 2: Finding Last Digits of Massive Powers

What are the last two digits of 17202617^{2026}?

Solution: Finding the last two digits is equivalent to finding x≡172026(mod100)x \equiv 17^{2026} \pmod{100}. Computing modulo 100 directly is tedious, but 100=4×25100 = 4 \times 25, and gcd⁡(4,25)=1\gcd(4, 25) = 1. We can compute the remainders modulo 4 and modulo 25 separately.

Modulo 4:

17≡1(mod4)  ⟹  172026≡12026≡1(mod4)17 \equiv 1 \pmod{4} \implies 17^{2026} \equiv 1^{2026} \equiv 1 \pmod{4}

Modulo 25:

We can use Euler's Totient Theorem. ϕ(25)=25×(1−1/5)=20\phi(25) = 25 \times (1 - 1/5) = 20. Therefore, 1720≡1(mod25)17^{20} \equiv 1 \pmod{25}. We divide the exponent: 2026=20×101+62026 = 20 \times 101 + 6.

172026≡(1720)101⋅176≡1⋅176(mod25)17^{2026} \equiv (17^{20})^{101} \cdot 17^6 \equiv 1 \cdot 17^6 \pmod{25}

17^2026 \equiv (17^20)^101 \cdot 17^6 \equiv 1 \cdot 17^6 \pmod25

Calculate $17^6 \pmod{25}$ step-by-step: $17 \equiv -8 \pmod{25}$ $17^2 \equiv 64 \equiv 14 \pmod{25}$ $17^4 \equiv 14^2 = 196 \equiv 21 \equiv -4 \pmod{25}$ $17^6 = 17^4 \cdot 17^2 \equiv (-4) \cdot 14 = -56 \equiv 19 \pmod{25}$ Now we have the system:

x \equiv 1 \pmod4 \ x \equiv 19 \pmod25

From the second equation, $x = 25k + 19$. Substitute into the first:

25k + 19 \equiv 1 \pmod4 \ (1)k + 3 \equiv 1 \pmod4 \ k \equiv -2 \equiv 2 \pmod4

So, $k = 4j + 2$. Substitute back: $x = 25(4j + 2) + 19 = 100j + 69$. The last two digits are $69$.

Common Pitfalls

  • Forgetting the coprimality requirement: CRT only works cleanly if the moduli share no common factors.
  • Arithmetic errors in substitution: Reducing negative numbers incorrectly during the substitution steps (e.g., −3(mod5)-3 \pmod{5} is 22, not 33).
  • Losing the final modulus: The solution is unique modulo the product of all the coprime moduli, not just the largest one.

Practice Problems

StatusSourceProblem NameDifficultyTags
Berkeley Math CircleHard
Show TagsChinese remainder theorem, Factorization techniques
Berkeley Math Circle Monthly Contest 1Hard
Show TagsChinese remainder theorem, Greatest common divisors (gcd), Polynomials mod p
Berkeley Math Circle: Monthly Contest 6Hard
Show TagsChinese remainder theorem, Fermat / Euler / Wilson theorems, Multiplicative order
Berkeley Math Circle Monthly Contest 8Hard
Show TagsChinese remainder theorem, Greatest common divisors (gcd)
MathNetHard
Show TagsChinese remainder theorem, Recurrence relations
Harvard-MIT Math TournamentHard
Show TagsChinese remainder theorem, Factorization techniques
Harvard-MIT Math TournamentHard
Show TagsChinese remainder theorem, Factorization techniques, Recurrence relations
Harvard-MIT Math TournamentHard
Show TagsChinese remainder theorem, Prime numbers
Harvard-MIT Mathematics TournamentHard
Show TagsChinese remainder theorem, Factorization techniques
Harvard-MIT Mathematics TournamentHard
Show TagsChinese remainder theorem, Fermat / Euler / Wilson theorems, Recurrence relations
Team Selection TestHard
Show TagsChinese remainder theorem, Divisibility / Factorization, Fermat / Euler / Wilson theorems, Multiplicative order, φ (Euler's totient)
USAMOHard
Show TagsChinese remainder theorem, Factorization techniques, Greatest common divisors (gcd), Polynomials, Prime numbers, Quadratic residues
Harvard-MIT Mathematics TournamentHard
Show TagsChinese remainder theorem, Games / greedy algorithms, Integers
Harvard-MIT Mathematics TournamentHard
Show TagsCartesian coordinates, Chinese remainder theorem, Fermat / Euler / Wilson theorems, Recurrence relations, Trigonometry
Team Selection TestHard
Show TagsChinese remainder theorem, Determinants, Fermat / Euler / Wilson theorems, Polynomial interpolation: Newton, Lagrange, Polynomials mod p
13th Annual Harvard-MIT Mathematics TournamentHard
Show TagsChinese remainder theorem, Fermat / Euler / Wilson theorems, Vieta's formulas
Team Selection Test 2010Hard
Show TagsChinese remainder theorem, Prime numbers, Recurrence relations, Recursion, bijection
USAMOHard
Show TagsChinese remainder theorem, Greatest common divisors (gcd), Other, Prime numbers
HMMT November 2012Hard
Show TagsChinese remainder theorem, Fermat / Euler / Wilson theorems
Harvard-MIT Mathematics TournamentHard
Show TagsChinese remainder theorem, Complex numbers, Fermat / Euler / Wilson theorems, Recurrence relations
TSTSTHard
Show TagsChinese remainder theorem, Greatest common divisors (gcd), Injectivity / surjectivity, Prime numbers
HMMT November 2013Hard
Show TagsChinese remainder theorem, Multiplicative order, Sums and products
HMMT 2013Hard
Show TagsChinese remainder theorem, Inverses mod n, Prime numbers
HMMT November 2014Hard
Show TagsChinese remainder theorem, Prime numbers, Quadratic residues
HMMT November 2014Hard
Show TagsChinese remainder theorem, Factorization techniques, Multiplicative order, Recurrence relations

Module Progress:

Join the Discord Community!

Stuck on a problem, or don't understand a module? Join the Discord and get help with your doubts while making more math friends.

PrevNext