Solve Systems of Congruences Instantly
An advanced, step-by-step Chinese Remainder Theorem solver for number theory, computer science, and cryptography problems.
Advertisement Space 1 (e.g., 728x90)
1. Enter Congruences
Enter your system in the form `x ≡ a (mod n)`.
2. Solution
Your solution will appear here.
Advertisement Space 2 (e.g., 300x250 or Responsive)
The Ultimate Guide to the Chinese Remainder Theorem 🧮
Welcome to the most comprehensive Chinese Remainder Theorem calculator with steps. This page is designed not just as a Chinese Remainder Theorem solver, but as an educational deep-dive into this fascinating and powerful concept from number theory. We'll explore its formula, proof, problems, and real-world applications.
What is the Chinese Remainder Theorem?
The Chinese Remainder Theorem (CRT) is a result from number theory that provides a unique solution to a system of linear congruences, provided that the moduli are pairwise coprime (they share no common factors other than 1). In simpler terms, if you know the remainders of a number `x` when divided by several different numbers, the CRT helps you find the number `x` itself.
The problem is often stated like this: Find an integer `x` that satisfies the following system:
x ≡ a₁ (mod n₁)
x ≡ a₂ (mod n₂)
...
x ≡ aₖ (mod nₖ)
The theorem guarantees that as long as all the moduli (n₁, n₂, ..., nₖ) are pairwise coprime, there is a unique solution for `x` modulo N, where N is the product of all moduli (N = n₁ × n₂ × ... × nₖ).
The Chinese Remainder Theorem Formula and Steps
Our online Chinese Remainder Theorem calculator automates the solution process, but understanding the steps is key. Here's a breakdown of the standard algorithm for finding the Chinese Remainder Theorem solution.
- Check Coprimality: Ensure all moduli `nᵢ` are pairwise coprime. If any pair `(nᵢ, nⱼ)` has a greatest common divisor (GCD) greater than 1, the standard theorem doesn't apply directly (though solutions may still exist under certain conditions).
- Calculate N: Find the product of all moduli: `N = n₁ × n₂ × ... × nₖ`.
- Calculate Nᵢ: For each congruence `i`, calculate `Nᵢ = N / nᵢ`. This is the product of all moduli *except* `nᵢ`.
- Find Modular Multiplicative Inverse: For each `i`, find the inverse of `Nᵢ` modulo `nᵢ`. This is a number `yᵢ` such that `(Nᵢ × yᵢ) ≡ 1 (mod nᵢ)`. This is the most computationally intensive part and is solved using the Extended Euclidean Algorithm.
- The Grand Finale: The solution `x` is the sum of the products `aᵢ × Nᵢ × yᵢ`, all taken modulo N. The Chinese Remainder Theorem formula is:
x ≡ (a₁N₁y₁ + a₂N₂y₂ + ... + aₖNₖyₖ) (mod N)
This Chinese Remainder Theorem calculator with step-by-step details shows each of these values (N, Nᵢ, yᵢ) to make the process clear.
"There are things which are unknown, and there are things which are known; and in between there are doors." - Sun Tzu, The Art of War. (A fitting metaphor for the CRT, which opens the door to finding an unknown number from known remainders).
Chinese Remainder Theorem Example with Solution
Let's solve a classic problem. Find a number `x` such that:
x ≡ 2 (mod 3)
(a₁=2, n₁=3)x ≡ 3 (mod 5)
(a₂=3, n₂=5)x ≡ 2 (mod 7)
(a₃=2, n₃=7)
Using the steps above:
- Coprime Check: GCD(3,5)=1, GCD(3,7)=1, GCD(5,7)=1. They are pairwise coprime.
- Calculate N: N = 3 × 5 × 7 = 105.
- Calculate Nᵢ:
N₁ = 105 / 3 = 35
N₂ = 105 / 5 = 21
N₃ = 105 / 7 = 15 - Find Inverses (yᵢ):
Find y₁: 35y₁ ≡ 1 (mod 3) → 2y₁ ≡ 1 (mod 3) → y₁ = 2.
Find y₂: 21y₂ ≡ 1 (mod 5) → y₂ ≡ 1 (mod 5) → y₂ = 1.
Find y₃: 15y₃ ≡ 1 (mod 7) → y₃ ≡ 1 (mod 7) → y₃ = 1. - Calculate Final Solution:
x ≡ (a₁N₁y₁ + a₂N₂y₂ + a₃N₃y₃) (mod 105)
x ≡ (2×35×2 + 3×21×1 + 2×15×1) (mod 105)
x ≡ (140 + 63 + 30) (mod 105)
x ≡ 233 (mod 105)
x ≡ 23 (mod 105).
The smallest positive integer solution is 23.
Applications in Computer Science and Beyond
The CRT is not just an abstract mathematical puzzle; it's a cornerstone of modern computing and cryptography.
- Cryptography (RSA): The RSA algorithm, which secures much of the internet, uses the CRT to speed up decryption calculations significantly. Calculations can be performed modulo smaller prime factors and then combined, which is much faster than working with the large composite modulus directly.
- Computer Science: It's used in algorithms for working with large integers. A very large number can be represented by its remainders modulo several smaller, coprime numbers. Operations like addition and multiplication can be done on these smaller remainders in parallel, and the CRT is used to reconstruct the final large number. This is related to the time complexity of Chinese Remainder Theorem algorithms, which is efficient for these tasks.
- Coding Theory: Used in error-correcting codes like the Reed-Solomon code to recover original data from corrupted data.
- Polynomials: A more abstract version, the Chinese Remainder Theorem for polynomials, is used in fields like computer algebra.
The Chinese Remainder Theorem Proof and Theory
The proof of the CRT is constructive, meaning the proof itself shows you how to find the solution. It relies on the properties of the modular multiplicative inverse `yᵢ`. By constructing `Nᵢ` and finding its inverse `yᵢ` modulo `nᵢ`, we create a special number `eᵢ = Nᵢyᵢ`. This number has the unique property that `eᵢ ≡ 1 (mod nᵢ)` and `eᵢ ≡ 0 (mod nⱼ)` for all `j ≠ i`. The final solution `x` is then built as a weighted sum of these `eᵢ` terms, where the weights are the remainders `aᵢ`.
The concept also extends to abstract algebra, where the Chinese Remainder Theorem for rings provides a powerful way to understand the structure of quotient rings.
Conclusion: A Bridge Between Worlds
The Chinese Remainder Theorem is a beautiful piece of mathematics that serves as a bridge between the world of integers and the world of modular arithmetic. It elegantly solves a class of problems that appear in ancient puzzles and modern cryptography alike. By using this Chinese Remainder Theorem solver with steps, we hope you not only get your answer quickly but also gain a deeper appreciation for the structure and beauty of number theory.
Support Our Work ❤️
If you find this tool helpful, please consider a donation to help us keep it free, ad-free, and constantly improving. Every little bit helps!
Donate via UPI
Scan the QR code for a quick and easy UPI payment in India.

Support via PayPal
Contribute securely using your PayPal account from anywhere in the world.

Advertisement Space 3 (e.g., Footer Banner)