Chapter

Chinese Remainder Theorem

The module develops CRT as a method for solving systems of congruences and as an olympiad construction tool: compatibility, non-coprime moduli, shifts, blocks of composite numbers, and constructions with prescribed divisors.
Log in to track solved progress and bookmarks.

Theory

Key Idea

The Chinese Remainder Theorem lets us construct a number with several prescribed residues at once. In olympiad problems it is not only a way to solve systems of congruences, but also a method for constructing numbers with planned divisibility.

If the moduli are pairwise coprime, the system has a unique solution modulo the product of the moduli. If the moduli are not coprime, compatibility of residues modulo common divisors must be checked first.

Basic Facts

  • If \(\gcd(m,n)=1\), then \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) has a unique solution modulo \(mn\).
  • For several pairwise coprime moduli, the solution is unique modulo their product.
  • The system \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) is compatible if and only if \(a\equiv b\pmod{\gcd(m,n)}\).
  • If one solution \(x_0\) is found, all solutions are \(x=x_0+k\operatorname{lcm}(m_1,\ldots,m_s)\).
  • Conditions of the form \(d\mid n+r\) are conveniently rewritten as \(n\equiv-r\pmod d\).

When to Use This Method

  • You need a number with several prescribed residues.
  • You need to prove existence of a number with prescribed divisibility of \(n+a_i\).
  • A large modulus splits into coprime parts.
  • You need to construct a counterexample or an infinite family of numbers.
  • You need to prove that a system of congruences is impossible because of a common-divisor conflict.

How to Recognise the Method

If the problem simultaneously says “when divided by \(3\)”, “when divided by \(5\)”, and “divisible by \(7\)”, translate the conditions into a system of congruences. If numbers \(n+1,n+2,\ldots\) must have different divisors, write one congruence for each shift.

Before solving the system, inspect the moduli. Pairwise coprimality gives direct CRT; common divisors require compatibility checks.

Typical Mistakes

  • Multiplying moduli immediately even though they are not coprime.
  • Forgetting that the answer is modulo the LCM, not necessarily modulo the product.
  • Writing \(n\equiv r\pmod d\) instead of \(n\equiv-r\pmod d\) from \(d\mid n+r\).
  • Finding one solution but not describing all solutions.
  • In constructions, forgetting to check that the constructed numbers are larger than their nontrivial divisors.

Mini-Checklist

  • Have all conditions been written as congruences?
  • Are the moduli pairwise coprime?
  • If not, are the residues compatible modulo the GCD?
  • What is the final modulus of the answer: product or LCM?
  • Do we need the smallest positive solution or all solutions?
  • If this is a construction, why does it give infinitely many numbers?

Examples

Example 1. Two Coprime Moduli

Basic CRT: substitute one congruence into the other.

Problem. Solve \(x\equiv2\pmod3\), \(x\equiv3\pmod5\).

Solution.

Let \(x=3k+2\). Then \(3k+2\equiv3\pmod5\), so \(3k\equiv1\pmod5\). Multiplying by the inverse \(2\) of \(3\), \(k\equiv2\pmod5\). Thus \(x=3(5t+2)+2=15t+8\). The answer is \(x\equiv8\pmod{15}\).

Comment. The moduli \(3\) and \(5\) are coprime, so the answer is unique modulo \(15\).

Example 2. Compatible Non-Coprime Moduli

If moduli have a common divisor, check residues first.

Problem. Solve \(x\equiv4\pmod6\), \(x\equiv1\pmod9\).

Solution.

The common divisor of \(6\) and \(9\) is \(3\). The residues \(4\) and \(1\) are congruent modulo \(3\), so the system is compatible. Let \(x=6k+4\). Then \(6k+4\equiv1\pmod9\), so \(6k\equiv6\pmod9\). Divide by \(3\): \(2k\equiv2\pmod3\), hence \(k\equiv1\pmod3\). Therefore \(x\equiv10\pmod{18}\).

Comment. The answer is modulo \(\operatorname{lcm}(6,9)=18\).

Example 3. Incompatibility

Sometimes CRT is used to quickly prove that no solution exists.

Problem. Prove that \(x\equiv2\pmod6\), \(x\equiv4\pmod9\) has no solutions.

Solution.

The first congruence gives \(x\equiv2\pmod3\). The second gives \(x\equiv1\pmod3\). One number cannot have two different residues modulo \(3\). Hence there are no solutions.

Comment. This is exactly the GCD compatibility check.

Example 4. Constructing a Number

CRT constructs a number with prescribed residues without searching a large range.

Problem. Find the smallest positive \(n\) such that \(n\equiv1\pmod2\), \(n\equiv2\pmod3\), \(n\equiv3\pmod5\).

Solution.

Check numbers \(n\equiv3\pmod5\): \(3,8,13,18,23,\ldots\). Among them, \(n\equiv2\pmod3\) holds for \(8,23,\ldots\). The first odd one is \(23\). The answer is \(23\). All solutions are \(n\equiv23\pmod{30}\).

Comment. For small moduli, careful hand search is fine.

Example 5. Infinitely Many Solutions

Once one solution is found, we automatically get an infinite family.

Problem. Prove that there are infinitely many \(n\) such that \(n\equiv1\pmod2\), \(n\equiv2\pmod3\), \(n\equiv3\pmod5\).

Solution.

From the previous example, one solution is \(n=23\). Since \(2,3,5\) are pairwise coprime, all solutions are \(n=23+30t\), where \(t\in\mathbb Z\). For \(t=0,1,2,\ldots\), this gives infinitely many positive solutions.

Comment. CRT often gives not one number, but an entire arithmetic progression.

Example 6. Divisibility of Shifts

Conditions on \(n+r\) become residues for \(n\).

Problem. Find the smallest positive \(n\) such that \(5\mid n+1\), \(7\mid n+2\), \(11\mid n+3\).

Solution.

Rewrite as \(n\equiv-1\pmod5\), \(n\equiv-2\pmod7\), \(n\equiv-3\pmod{11}\). That is, \(n\equiv4\pmod5\), \(n\equiv5\pmod7\), \(n\equiv8\pmod{11}\). Checking gives \(n=19\): \(20\) is divisible by \(5\), \(21\) by \(7\), \(22\) by \(11\). All solutions are \(n\equiv19\pmod{385}\).

Comment. This is a typical language of CRT constructions.

Example 7. A Block of Composite Numbers

CRT and factorials build long blocks of numbers with planned divisors.

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

Solution.

Take \(N=6!\). Then \(N+2,N+3,N+4,N+5,N+6\) are divisible respectively by \(2,3,4,5,6\). Each is larger than the corresponding divisor, so all are composite. These are \(5\) consecutive numbers.

Comment. The factorial is a very fast special case of a CRT construction.

Example 8. An Impossible Construction

Not every residue system exists.

Problem. Is there an integer \(x\) such that \(x\equiv4\pmod6\) and \(x\equiv9\pmod{10}\)?

Solution.

The first congruence gives \(x\equiv0\pmod2\), while the second gives \(x\equiv1\pmod2\). Contradiction. Therefore no such number exists.

Comment. The fastest test is to compare residues modulo the common divisor \(2\).

Problems

Problems

#13.1
#13.1

System Modulo \(4\) and \(5\)

Chinese Remainder Theorem Grade 8 Grade 9 ★☆☆☆☆

Find the smallest positive \(x\) such that \(x\equiv1\pmod4\), \(x\equiv2\pmod5\).

Details
Problem: NT-B1-M08-P001
Difficulty: Level 1 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.2
#13.2

System Modulo \(5\) and \(7\)

Chinese Remainder Theorem Grade 8 Grade 9 ★☆☆☆☆

Find the smallest positive \(x\) such that \(x\equiv4\pmod5\), \(x\equiv6\pmod7\).

Details
Problem: NT-B1-M08-P002
Difficulty: Level 1 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.3
#13.3

System Modulo \(8\) and \(9\)

Chinese Remainder Theorem Grade 8 Grade 9 ★☆☆☆☆

Solve \(x\equiv5\pmod8\), \(x\equiv7\pmod9\).

Details
Problem: NT-B1-M08-P003
Difficulty: Level 1 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.4
#13.4

Parity Conflict

No Solution Grade 8 Grade 9 ★☆☆☆☆

Prove that \(x\equiv1\pmod2\), \(x\equiv0\pmod4\) has no solutions.

Details
Problem: NT-B1-M08-P004
Difficulty: Level 1 of 5
Tag: No Solution
Grade: Grade 8, Grade 9
#13.5
#13.5

Equal Residues

Chinese Remainder Theorem Grade 8 Grade 9 ★☆☆☆☆

Describe all \(x\) such that \(x\equiv3\pmod5\) and \(x\equiv3\pmod7\).

Details
Problem: NT-B1-M08-P005
Difficulty: Level 1 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.6
#13.6

Three Moduli

Chinese Remainder Theorem Grade 8 Grade 9 ★★☆☆☆

Find the smallest positive \(x\) such that \(x\equiv1\pmod3\), \(x\equiv2\pmod4\), \(x\equiv3\pmod5\).

Details
Problem: NT-B1-M08-P006
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.7
#13.7

Shifts \(n+1,n+2,n+3\)

Chinese Remainder Theorem Grade 8 Grade 9 ★★☆☆☆

Find the smallest positive \(n\) such that \(2\mid n+1\), \(3\mid n+2\), \(5\mid n+3\).

Details
Problem: NT-B1-M08-P007
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.8
#13.8

Compatible System

Non-coprime Grade 8 Grade 9 ★★☆☆☆

Solve \(x\equiv5\pmod8\), \(x\equiv9\pmod{12}\).

Details
Problem: NT-B1-M08-P008
Difficulty: Level 2 of 5
Tag: Non-coprime
Grade: Grade 8, Grade 9
#13.9
#13.9

Another Compatible System

Non-coprime Grade 8 Grade 9 ★★☆☆☆

Solve \(x\equiv4\pmod6\), \(x\equiv10\pmod{15}\).

Details
Problem: NT-B1-M08-P009
Difficulty: Level 2 of 5
Tag: Non-coprime
Grade: Grade 8, Grade 9
#13.10
#13.10

Incompatible System

No Solution Grade 8 Grade 9 ★★☆☆☆

Prove that \(x\equiv4\pmod6\), \(x\equiv9\pmod{10}\) has no solutions.

Details
Problem: NT-B1-M08-P010
Difficulty: Level 2 of 5
Tag: No Solution
Grade: Grade 8, Grade 9
#13.11
#13.11

Residues \(2,4,6\)

Chinese Remainder Theorem Grade 8 Grade 9 ★★☆☆☆

Find the smallest positive \(x\) such that \(x\equiv2\pmod3\), \(x\equiv4\pmod5\), \(x\equiv6\pmod7\).

Details
Problem: NT-B1-M08-P011
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.12
#13.12

Four Moduli

Chinese Remainder Theorem Grade 8 Grade 9 ★★☆☆☆

Find the smallest positive \(x\) such that \(x\equiv1\pmod2\), \(x\equiv2\pmod3\), \(x\equiv3\pmod5\), \(x\equiv4\pmod7\).

Details
Problem: NT-B1-M08-P012
Difficulty: Level 2 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 8, Grade 9
#13.13
#13.13

Compatibility Criterion

Compatibility Grade 9 Grade 10 ★★★☆☆

Prove that \(x\equiv a\pmod m\), \(x\equiv b\pmod n\) has a solution if and only if \(a\equiv b\pmod{\gcd(m,n)}\).

Details
Problem: NT-B1-M08-P013
Difficulty: Level 3 of 5
Tag: Compatibility
Grade: Grade 9, Grade 10
#13.14
#13.14

Four Composite Numbers in a Row

Construction Grade 9 Grade 10 ★★★☆☆

Find \(n\) such that \(n+2,n+3,n+4,n+5\) are composite numbers.

Details
Problem: NT-B1-M08-P014
Difficulty: Level 3 of 5
Tag: Construction
Grade: Grade 9, Grade 10
#13.15
#13.15

Arbitrarily Many Composite Numbers

Construction Grade 9 Grade 10 ★★★☆☆

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

Details
Problem: NT-B1-M08-P015
Difficulty: Level 3 of 5
Tag: Construction
Grade: Grade 9, Grade 10
#13.16
#13.16

Three Prescribed Divisors

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

Find all \(n\) such that \(5\mid n+1\), \(7\mid n+2\), \(11\mid n+3\).

Details
Problem: NT-B1-M08-P016
Difficulty: Level 3 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.17
#13.17

Shifts with \(3,5,7\)

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

Find the smallest positive \(n\) such that \(3\mid n+1\), \(5\mid n+2\), \(7\mid n+3\).

Details
Problem: NT-B1-M08-P017
Difficulty: Level 3 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.18
#13.18

A System Modulo \(900\)

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

Solve \(x\equiv3\pmod4\), \(x\equiv7\pmod9\), \(x\equiv12\pmod{25}\).

Details
Problem: NT-B1-M08-P018
Difficulty: Level 3 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.19
#13.19

Residues Modulo \(5,8,9\)

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

Find the smallest positive \(x\) if \(x\equiv1\pmod5\), \(x\equiv3\pmod8\), \(x\equiv4\pmod9\).

Details
Problem: NT-B1-M08-P019
Difficulty: Level 3 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.20
#13.20

Residues Modulo \(7,9,11\)

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

Find the smallest positive \(x\) such that \(x\equiv2\pmod7\), \(x\equiv5\pmod9\), \(x\equiv8\pmod{11}\).

Details
Problem: NT-B1-M08-P020
Difficulty: Level 3 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.21
#13.21

CRT for Several Moduli

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

Let \(m_1,\ldots,m_s\) be pairwise coprime. Explain why the system \(x\equiv a_i\pmod{m_i}\) has infinitely many integer solutions.

Details
Problem: NT-B1-M08-P021
Difficulty: Level 4 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.22
#13.22

Prescribed Divisors of Shifts

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

Let \(d_1,\ldots,d_k\) be pairwise coprime. Prove that there are infinitely many \(n\) such that \(d_i\mid n+i\) for all \(i=1,\ldots,k\).

Details
Problem: NT-B1-M08-P022
Difficulty: Level 4 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.23
#13.23

A Block with Prescribed Prime Divisors

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

Prove that there exist \(6\) consecutive positive integers, each divisible respectively by one of \(5,7,11,13,17,19\).

Details
Problem: NT-B1-M08-P023
Difficulty: Level 4 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
#13.24
#13.24

Consecutive Non-Squarefree Numbers

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

Prove that for every \(k\ge1\), there exist \(k\) consecutive positive integers, each divisible by the square of some prime.

Details
Problem: NT-B1-M08-P024
Difficulty: Level 5 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10

Ladders

No published ladders were found.
Previous Chapter
Next Chapter