How solving two modular equations simultaneously reveals a secret letter
The Chinese Remainder Theorem (CRT) is a cornerstone of number theory. It says: if you know the remainder of a number modulo two different (and coprime) moduli, you can uniquely determine that number modulo their product. The theorem dates back to Sunzi's work in 3rd-century China.
In this cipher, you're given a system of two congruences: x ≡ a (mod m) and x ≡ b (mod n), where m and n are coprime. You find the unique solution x modulo m×n. Then x mod 26 (A=0) gives the secret letter.
Solve: x ≡ 3 (mod 5) and x ≡ 2 (mod 7).
Step 1: Compute M = m × n = 5 × 7 = 35.
Step 2: Compute the modular inverses.
For modulus 5: M/m = 35/5 = 7. Need 7 × inv ≡ 1 (mod 5). 7 mod 5 = 2. inv of 2 mod 5 = 3 (since 2×3=6≡1). So inv₁ = 3. For modulus 7: M/n = 35/7 = 5. Need 5 × inv ≡ 1 (mod 7). 5 mod 7 = 5. inv of 5 mod 7 = 3 (since 5×3=15≡1). So inv₂ = 3.
Step 3: Combine using the CRT formula:
x = a × (M/m) × inv₁ + b × (M/n) × inv₂ (mod M) x = 3 × 7 × 3 + 2 × 5 × 3 (mod 35) x = 63 + 30 (mod 35) x = 93 (mod 35) 93 mod 35 = 93 - 2×35 = 93 - 70 = 23
Step 4: 23 mod 26 = 23 → X (since A=0, B=1, ..., X=23).
The answer is "x".
Verification: 23 mod 5 = 3 ✓, 23 mod 7 = 2 ✓.
The Chinese Remainder Theorem works because the moduli are coprime — they share no common factors. This means the mapping between numbers modulo m×n and pairs of remainders (mod m, mod n) is a bijection: every number in [0, m×n-1] corresponds to exactly one pair of remainders, and vice versa. The formula finds the unique solution by scaling each remainder by the product of the other moduli and its modular inverse, then summing them up.
| Level | Moduli | Notes |
|---|---|---|
| 1 | 3-9 | Small moduli, easy arithmetic |
| 2 | 7-17 | Slightly larger, more computation |
Check puzzle browser. If a Chinese Remainder puzzle is active, use the CRT formula to find x, then x mod 26 for the secret letter!