Congruences · Definition
Chinese remainder theorem
Before you start you need to know
Many counting and calendar problems reduce to solving several congruences at once. The Chinese remainder theorem lets you combine those conditions into a single equivalent congruence.
Definition
The Chinese remainder theorem states that a system of linear congruences with pairwise coprime moduli has a unique solution modulo the product of those moduli.
If \(m_1,\dots,m_k\) are pairwise coprime, the system \(x\equiv a_i \pmod{m_i}\) has a solution, and every other solution is congruent to it modulo \(M=m_1\cdots m_k\). The proof builds the solution with \(M_i=M/m_i\) and an inverse \(y_i\) of \(M_i\) modulo \(m_i\), giving \(x=\sum a_i M_i y_i\). The inverse exists because \(\gcd(M_i,m_i)=1\), which follows from coprimality.
To solve \(x\equiv 2 \pmod 3\) and \(x\equiv 3 \pmod 5\), take \(M=15\). With \(M_1=5\), the inverse of \(5\) modulo \(3\) is \(2\), and with \(M_2=3\), the inverse of \(3\) modulo \(5\) is \(2\). Thus \(x\equiv 2\cdot5\cdot2+3\cdot3\cdot2=38\equiv 8 \pmod{15}\), which checks out by dividing \(8\) by \(3\) and by \(5\).
A typical mistake is applying the theorem to moduli that are not coprime, such as \(x\equiv 0 \pmod 4\) and \(x\equiv 1 \pmod 6\), where there is no solution because \(x\) would have to be both even and odd. Before using the theorem, check that \(\gcd(m_i,m_j)=1\) for every pair of moduli.
Think about it
Why is it enough for the moduli to be pairwise coprime?
Because each \(M_i=M/m_i\) is coprime to \(m_i\), so it has an inverse modulo \(m_i\).
Exercises 10
- What condition must the moduli \(m_1,\dots,m_k\) satisfy to apply the Chinese remainder theorem?
- What is the modulus of the system \(x\equiv 1 \pmod 2\), \(x\equiv 2 \pmod 3\), \(x\equiv 4 \pmod 5\)?
- If \(x\equiv a \pmod{m}\) and \(x\equiv b \pmod{n}\) with \(\mathrm{gcd}(m,n)=1\), which congruence describes all solutions?
- Which number between \(0\) and \(11\) satisfies \(x\equiv 1 \pmod 3\) and \(x\equiv 0 \pmod 4\)?
- How many distinct solutions modulo \(M=m_1m_2\) does the system with coprime moduli \(m_1\) and \(m_2\) have?
- Solve \(x\equiv 2 \pmod 3\) and \(x\equiv 3 \pmod 4\). What is the least positive residue of \(x\) modulo \(12\)?
- Solve \(x\equiv 1 \pmod 5\) and \(x\equiv 2 \pmod 7\). What is the smallest positive integer \(x\) satisfying both?
- Solve \(x\equiv 3 \pmod 4\) and \(x\equiv 4 \pmod 5\). What is the residue of \(x\) modulo \(20\)?
- A system with \(x\equiv 0 \pmod 6\) and \(x\equiv 1 \pmod 4\). Does it have a solution? Choose the correct statement.
- Solve the system \(x\equiv 2 \pmod 3\), \(x\equiv 3 \pmod 5\), \(x\equiv 2 \pmod 7\). What is the residue of \(x\) modulo \(105\)?
References
- David M. Burton, Elementary Number Theory, 7th edition, McGraw-Hill, 2011. cap. 4
- Ivan Niven, Herbert S. Zuckerman, Hugh L. Montgomery, An Introduction to the Theory of Numbers, 5th edition, Wiley, 1991. cap. 2