Sub topic 14
Combining Remainder Conditions with the Chinese Remainder Theorem
This chapter assumes that you can divide integers with remainders, use congruence notation, and factor numbers into primes. You should also know basic exponent rules and divisibility tests.
What the Chinese Remainder Theorem does
A remainder condition such as
\[ x \equiv 2 \pmod{3} \]
means that \(x\) leaves remainder 2 when divided by 3. A system combines several such conditions:
\[ x \equiv 2 \pmod{3}, \qquad x \equiv 3 \pmod{5}, \qquad x \equiv 2 \pmod{7}. \]
The Chinese Remainder Theorem says that if the moduli are pairwise coprime, then the system has exactly one solution modulo their product.
Two numbers are coprime when their greatest common divisor is 1. The numbers 3, 5, and 7 are pairwise coprime, so this system has one answer between 0 and \(3 \times 5 \times 7-1=104\).
| Condition | Meaning |
|---|---|
| \(x \equiv 2 \pmod{3}\) | \(x\) is 2 more than a multiple of 3 |
| \(x \equiv 3 \pmod{5}\) | \(x\) is 3 more than a multiple of 5 |
| \(x \equiv 2 \pmod{7}\) | \(x\) is 2 more than a multiple of 7 |
Solve by successive substitution
Start with the first condition:
\[ x=3k+2. \]
Use the second condition:
\[ 3k+2 \equiv 3 \pmod{5}. \]
Therefore,
\[ 3k \equiv 1 \pmod{5}. \]
Testing small values, \(k=2\) gives \(3k=6\equiv1\pmod5\). Thus \(k=5t+2\), and
\[ x=3(5t+2)+2=15t+8. \]
Now use the third condition:
\[ 15t+8\equiv2\pmod7. \]
Since \(15\equiv1\pmod7\) and \(8\equiv1\pmod7\),
\[ t+1\equiv2\pmod7, \]
so \(t\equiv1\pmod7\). Taking the smallest value \(t=1\),
\[ x=15(1)+8=23. \]
The complete set of solutions is
\[ x\equiv23\pmod{105}. \]
Thus 23 is the unique solution from 0 through 104.
x = next(
x for x in range(105)
if x % 3 == 2 and x % 5 == 3 and x % 7 == 2
)
print(x) # 23A CAT Quant method
For small moduli, successive substitution is usually faster than writing the full theorem formula. Combine two conditions, then test the resulting arithmetic progression against the third condition.
For example, \(x\equiv2\pmod3\) gives candidates \(2,5,8,11,\ldots\). Among these, \(x\equiv3\pmod5\) gives \(8,23,38,\ldots\). Testing these modulo 7 quickly gives 23.
A solution is not complete until you verify every original condition.
Exercise
Find the smallest non-negative integer x satisfying x ≡ 1 mod 4 and x ≡ 2 mod 3.
Show answer
The candidates from the first condition are 1, 5, 9, 13, ... . The first one that leaves remainder 2 when divided by 3 is 5, so x = 5.