Chinese Remainder Theorem Calculator
Solve a system of congruences of the form x = remainder mod modulus, using two or three equations. It returns the smallest solution and the general form of all solutions.
1 Fill in the boxes
2 Your answer
Your answer shows here as you type.
How to use the Chinese Remainder Theorem Calculator
- Enter each remainder and its modulus. The default gives x = 2 mod 3, x = 3 mod 5, x = 2 mod 7.
- Leave the third pair empty to solve with two equations.
- Read the smallest solution and the combined modulus. Every whole number of the form solution plus modulus times k also works.
Frequently asked questions
What is the Chinese Remainder Theorem?
If the moduli are pairwise coprime, the system x = a_i mod m_i has exactly one solution modulo the product of all the moduli. For example, x = 2 mod 3, x = 3 mod 5, x = 2 mod 7 has the solution x = 23 mod 105.
What if the moduli share a common factor?
A solution exists only when each pair of remainders agrees modulo the greatest common divisor of their moduli. When it does, the solutions repeat every least common multiple of the moduli.
How is the solution calculated?
Two congruences are combined at a time. The extended Euclidean algorithm gives a modular inverse, which finds the shift needed to satisfy both, and the result is then combined with the next congruence.
Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.