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=m1m2mkM = 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:

  • x2(mod3)x \equiv 2 \pmod{3}
  • x3(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
x2(mod3)x \equiv 2 \pmod{3}2, 5, 8, 11, 14, 17, 20, 23, 26, 29
x3(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 iji \neq j), the system xai(modmi)x \equiv a_i \pmod{m_i} has a unique solution modulo M=m1m2mkM = 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=m1k+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 xa(modm)x \equiv a \pmod{m} and xb(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 xa(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:

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

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

Now we have a two-congruence system:

x2(mod21)x3(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+23(mod5)21k + 2 \equiv 3 \pmod{5}

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

k+23(mod5)    k1(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, x23(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 x172026(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:

171(mod4)    172026120261(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×(11/5)=20\phi(25) = 25 \times (1 - 1/5) = 20. Therefore, 17201(mod25)17^{20} \equiv 1 \pmod{25}. We divide the exponent: 2026=20×101+62026 = 20 \times 101 + 6.

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

Calculate 176(mod25)17^6 \pmod{25} step-by-step: 178(mod25)17 \equiv -8 \pmod{25} 1726414(mod25)17^2 \equiv 64 \equiv 14 \pmod{25} 174142=196214(mod25)17^4 \equiv 14^2 = 196 \equiv 21 \equiv -4 \pmod{25} 176=174172(4)14=5619(mod25)17^6 = 17^4 \cdot 17^2 \equiv (-4) \cdot 14 = -56 \equiv 19 \pmod{25}

Now we have the system:

x1(mod4)x19(mod25)x \equiv 1 \pmod{4} \\ x \equiv 19 \pmod{25}

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

25k+191(mod4)(1)k+31(mod4)k22(mod4)25k + 19 \equiv 1 \pmod{4} \\ (1)k + 3 \equiv 1 \pmod{4} \\ k \equiv -2 \equiv 2 \pmod{4}

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

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

Module Progress:

Join the AoPS Community!

Stuck on a problem, or don't understand a module? Join the AoPS community and get help from other math contest students.

PrevNext