Chapter

Chinese Remainder Theorem and Construction

This module teaches CRT for systems of congruences, compatibility, counting solutions, and olympiad constructions.
Log in to track solved progress and bookmarks.

Theory

Key Idea

The Chinese Remainder Theorem turns several local conditions into one integer. In olympiad problems it is not only a way to “solve a system”, but also a language for constructions: we prescribe residues so that desired divisibilities become automatic.

The main principle is: if the moduli are pairwise coprime, then the system \(x\equiv r_i\pmod {m_i}\) is solvable and has a unique solution modulo \(M=m_1m_2\cdots m_k\).

Basic Facts

1. If \(\gcd(m,n)=1\), then \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) has a unique solution modulo \(mn\).

2. If the moduli are not coprime, \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) is solvable if and only if \(\gcd(m,n)\mid a-b\).

3. For pairwise coprime moduli, the number of solutions can be multiplied: for example, the number of solutions of \(x^2\equiv 1\pmod {mn}\) equals the product of the numbers of solutions modulo \(m\) and modulo \(n\).

4. In constructions, one often chooses primes \(p_i\) and imposes \(N+i\equiv 0\pmod {p_i}\). Then each \(N+i\) has a prescribed divisor.

When To Use This Method

Use CRT when a problem asks you to construct a number with several residues, prove existence of infinitely many integers, test compatibility of conditions, or organise divisibility of several expressions \(N+a_i\).

How To Recognise The Method

Signals include: “find a number with residues...”, “construct \(n\) so that \(n+i\) is divisible by...”, “prove that infinitely many exist”, “system of congruences”, and “simultaneously modulo several moduli”.

Typical Mistakes

Do not apply the standard CRT form without checking coprimality. If the moduli share a divisor, the residues must be compatible.

In compositeness constructions, it is not enough to get \(p_i\mid N+i\): one must also ensure \(N+i>p_i\), otherwise the number may equal its assigned divisor.

Mini-Checklist

1. Which moduli are involved, and are they pairwise coprime?

2. If the moduli are not coprime, are the residues compatible?

3. Modulo what number is the solution unique?

4. If a composite number is being constructed, is it larger than its assigned divisor?

5. Is one number needed or infinitely many? For infinitely many, add the period \(M\).

Examples

Example 1. Two Coprime Moduli

A basic CRT computation is best done by hand to see the period.

Problem. Find all \(x\) such that \(x\equiv 2\pmod 5\) and \(x\equiv 3\pmod 7\).

Solution.

Let \(x=5t+2\). Then \(5t+2\equiv 3\pmod 7\), so \(5t\equiv 1\pmod 7\). Since \(5^{-1}\equiv 3\pmod 7\), \(t\equiv 3\pmod 7\). Hence \(x=5(7s+3)+2=35s+17\). The answer is \(x\equiv 17\pmod {35}\).

Example 2. Compatible Non-Coprime Residues

If the moduli are not coprime, first check the common divisor.

Problem. Does \(x\equiv 2\pmod 6\), \(x\equiv 5\pmod 9\) have solutions?

Solution.

The common divisor is \(3\). The difference of residues is \(5-2=3\), divisible by \(3\), so the system is compatible. Let \(x=6t+2\). Then \(6t+2\equiv 5\pmod 9\), so \(6t\equiv 3\pmod 9\), or \(2t\equiv 1\pmod 3\). Thus \(t\equiv 2\pmod 3\), and \(x\equiv 14\pmod {18}\).

Example 3. Prescribed Divisors

CRT conveniently constructs numbers with prescribed divisors.

Problem. Construct \(N\) such that \(N+1\) is divisible by \(3\), \(N+2\) by \(5\), and \(N+3\) by \(7\).

Solution.

We need \(N\equiv -1\pmod 3\), \(N\equiv -2\pmod 5\), \(N\equiv -3\pmod 7\), or \(N\equiv 2\pmod 3\), \(N\equiv 3\pmod 5\), \(N\equiv 4\pmod 7\). Solving successively gives \(N\equiv 53\pmod {105}\). For example, \(N=53\).

Example 4. A Block of Composite Numbers

For a number to be composite, its prescribed divisor must be smaller than the number itself.

Problem. Prove that there exist \(6\) consecutive composite integers.

Solution.

Take \(N=7!-1\). Then \(N+2,N+3,\ldots,N+7\) are divisible by \(2,3,\ldots,7\), respectively. They are all larger than their assigned divisors, so they are composite. This gives a block of \(6\) consecutive composite integers.

Example 5. Counting Via CRT

When the moduli are coprime, solutions modulo different moduli can be combined independently.

Problem. How many solutions does \(x^2\equiv 1\pmod {105}\) have?

Solution.

Since \(105=3\cdot 5\cdot 7\), solve \(x^2\equiv 1\) modulo \(3,5,7\). For each odd prime modulus there are two solutions: \(x\equiv \pm 1\). Therefore the total number of solutions modulo \(105\) is \(2\cdot 2\cdot 2=8\).

Example 6. A Linear Expression

Sometimes one must first translate a condition on an expression into a condition on \(n\).

Problem. Find all \(n\) such that \(2n+1\equiv 0\pmod 5\) and \(3n-1\equiv 0\pmod 7\).

Solution.

The first congruence gives \(2n\equiv -1\equiv 4\pmod 5\), so \(n\equiv 2\pmod 5\). The second gives \(3n\equiv 1\pmod 7\), so \(n\equiv 5\pmod 7\). Solving the system, we get \(n\equiv 12\pmod {35}\).

Example 7. Proving Compatibility

The theorem for two non-coprime moduli often avoids unnecessary search.

Problem. Prove that \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) is solvable if and only if \(\gcd(m,n)\mid a-b\).

Solution.

If a solution \(x\) exists, then \(x-a\) is divisible by \(m\), and \(x-b\) is divisible by \(n\). Hence \(a-b=(x-b)-(x-a)\) is divisible by \(d=\gcd(m,n)\). Conversely, suppose \(d\mid a-b\). Write \(m=dm_1\), \(n=dn_1\), where \(\gcd(m_1,n_1)=1\). We need \(x=a+mt\) such that \(a+mt\equiv b\pmod n\), or \(m_1t\equiv \frac{b-a}{d}\pmod {n_1}\). Since \(m_1\) is invertible modulo \(n_1\), such \(t\) exists.

Example 8. Infinitely Many Constructions

After one solution is found, add the common period.

Problem. Prove that there are infinitely many \(N\) such that \(N,N+2,N+6\) are all composite.

Solution.

Impose \(N\equiv 0\pmod 5\), \(N+2\equiv 0\pmod 7\), \(N+6\equiv 0\pmod {11}\). The moduli are coprime, so a solution exists modulo \(385\), and every number \(N+385t\) has the same divisibility properties. For all sufficiently large \(t\), each number is greater than its assigned divisor, hence all three are composite. There are infinitely many such \(t\).

Problems

Problems

#9.1
#9.1

Two Residues

Modular Arithmetic Grade 9 Grade 10 ★★☆☆☆

Find all integers \(x\) such that \(x\equiv 4\pmod 9\) and \(x\equiv 7\pmod {11}\).

Details
Problem: NT-B2-M09-P001
Difficulty: Level 2 of 5
Tag: Modular Arithmetic
Grade: Grade 9, Grade 10
#9.2
#9.2

Three Residues

Modular Arithmetic Grade 9 Grade 10 ★★☆☆☆

Find the least positive \(x\) such that \(x\equiv 1\pmod 4\), \(x\equiv 2\pmod 5\), \(x\equiv 3\pmod 7\).

Details
Problem: NT-B2-M09-P002
Difficulty: Level 2 of 5
Tag: Modular Arithmetic
Grade: Grade 9, Grade 10
#9.3
#9.3

An Incompatible System

Chinese Remainder Theorem Grade 9 Grade 10 ★★☆☆☆

Prove that the system \(x\equiv 2\pmod 6\), \(x\equiv 3\pmod 9\) has no solutions.

Details
Problem: NT-B2-M09-P003
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#9.4
#9.4

A Compatible System With a Common Divisor

Chinese Remainder Theorem Grade 9 Grade 10 ★★☆☆☆

Solve the system \(x\equiv 5\pmod {12}\), \(x\equiv 17\pmod {18}\).

Details
Problem: NT-B2-M09-P004
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#9.5
#9.5

Prescribed Residues

Chinese Remainder Theorem Grade 9 Grade 10 ★★☆☆☆

Construct a positive \(N\) such that \(N\equiv 2\pmod 3\), \(N\equiv 4\pmod 5\), \(N\equiv 6\pmod 7\).

Details
Problem: NT-B2-M09-P005
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#9.6
#9.6

Three Consecutive Divisibilities

Divisibility Grade 9 Grade 10 ★★★☆☆

Find the least positive \(N\) such that \(N+1\) is divisible by \(4\), \(N+2\) by \(5\), and \(N+3\) by \(9\).

Details
Problem: NT-B2-M09-P006
Difficulty: Level 3 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
#9.7
#9.7

Two Linear Conditions

Chinese Remainder Theorem Grade 9 Grade 10 ★★★☆☆

Find all \(n\) such that \(4n+1\) is divisible by \(9\), and \(5n-2\) is divisible by \(11\).

Details
Problem: NT-B2-M09-P007
Difficulty: Level 3 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#9.8
#9.8

A Block of Four Composites

Divisibility Grade 9 Grade 10 ★★★☆☆

Construct \(N\) such that \(N+1,N+2,N+3,N+4\) are composite.

Details
Problem: NT-B2-M09-P008
Difficulty: Level 3 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
#9.9
#9.9

Squares Modulo a Composite

Counting Grade 9 Grade 10 ★★★☆☆

How many solutions does \(x^2\equiv 1\pmod {385}\) have?

Details
Problem: NT-B2-M09-P009
Difficulty: Level 3 of 5
Tag: Counting
Grade: Grade 9, Grade 10
#9.10
#9.10

Find All Four Solutions

Counting Grade 9 Grade 10 ★★★☆☆

Find all solutions of \(x^2\equiv 1\pmod {35}\) modulo \(35\).

Details
Problem: NT-B2-M09-P010
Difficulty: Level 3 of 5
Tag: Counting
Grade: Grade 9, Grade 10
#9.11
#9.11

Compatibility Criterion

Chinese Remainder Theorem Grade 10 Grade 11 ★★★★☆

Let \(m,n,a,b\) be integers with \(m,n>0\). Prove that \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) has a solution if and only if \(\gcd(m,n)\mid a-b\).

Details
Problem: NT-B2-M09-P011
Difficulty: Level 4 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 10, Grade 11
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 276
#9.12
#9.12

Divisors for Five Shifts

Divisibility Grade 10 Grade 11 ★★★★☆

Prove that there are infinitely many \(N\) such that \(N+1,N+2,N+3,N+4,N+5\) have divisors \(3,5,7,11,13\), respectively.

Details
Problem: NT-B2-M09-P012
Difficulty: Level 4 of 5
Tag: Divisibility
Grade: Grade 10, Grade 11
#9.13
#9.13

Composite Triples

Prime Factorisation Grade 10 Grade 11 ★★★★☆

Prove that there are infinitely many \(n\) such that \(n\), \(n+2\), and \(n+6\) are all composite.

Details
Problem: NT-B2-M09-P013
Difficulty: Level 4 of 5
Tag: Prime Factorisation
Grade: Grade 10, Grade 11
#9.14
#9.14

Square Roots of One Modulo 840

Counting Grade 10 Grade 11 ★★★★☆

How many solutions does \(x^2\equiv 1\pmod {840}\) have?

Details
Problem: NT-B2-M09-P014
Difficulty: Level 4 of 5
Tag: Counting
Grade: Grade 10, Grade 11
#9.15
#9.15

Arbitrary Residues

Chinese Remainder Theorem Grade 10 Grade 11 ★★★★☆

Let \(m_1,\ldots,m_k\) be pairwise coprime positive integers, and let \(r_1,\ldots,r_k\) be arbitrary integers. Prove that there exists an integer \(x\) such that \(x\equiv r_i\pmod {m_i}\) for all \(i\).

Details
Problem: NT-B2-M09-P015
Difficulty: Level 4 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 10, Grade 11
#9.16
#9.16

A Long Composite Block

Divisibility Grade 10 Grade 11 ★★★★☆

Prove that for every \(k\), there exist \(k\) consecutive positive composite integers.

Details
Problem: NT-B2-M09-P016
Difficulty: Level 4 of 5
Tag: Divisibility
Grade: Grade 10, Grade 11
#9.17
#9.17

Assigned Large Primes

Prime Factorisation Grade 10 Grade 11 ★★★★★

Prove that for every \(k\), there exist \(k\) consecutive positive integers, each divisible by a prime divisor greater than \(k\), and these prime divisors can be chosen pairwise distinct.

Details
Problem: NT-B2-M09-P017
Difficulty: Level 5 of 5
Tag: Prime Factorisation
Grade: Grade 10, Grade 11
#9.18
#9.18

Avoiding a Finite Set of Residues

Modular Arithmetic Grade 10 Grade 11 ★★★★★

Let \(m_1,\ldots,m_k\) be pairwise coprime moduli, and for each \(i\) let one residue \(a_i\pmod {m_i}\) be forbidden. Prove that there are infinitely many integers \(x\) that are not congruent to \(a_i\) modulo \(m_i\) for any \(i\).

Details
Problem: NT-B2-M09-P018
Difficulty: Level 5 of 5
Tag: Modular Arithmetic
Grade: Grade 10, Grade 11
#9.19
#9.19

Many Composite Values of Linear Expressions

Divisibility Grade 10 Grade 11 ★★★★★

Let \(a_1,\ldots,a_k\) be distinct integers. Prove that there are infinitely many \(N\) such that all numbers \(N+a_1,\ldots,N+a_k\) are composite.

Details
Problem: NT-B2-M09-P019
Difficulty: Level 5 of 5
Tag: Divisibility
Grade: Grade 10, Grade 11
#9.20
#9.20

A False Construction Idea

Chinese Remainder Theorem Grade 10 Grade 11 ★★★★★

Let \(p_1,\ldots,p_k\) be distinct odd primes. Is it true that one can choose an integer \(x\) which is not congruent to \(\pm 1\) modulo any \(p_i\), but satisfies \(x^2\equiv 1\pmod {p_1p_2\cdots p_k}\)?

Details
Problem: NT-B2-M09-P020
Difficulty: Level 5 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 10, Grade 11

Ladders

No published ladders were found.
Previous Chapter
Next Chapter