Chinese Remainder Theorem Calculator

Chinese Remainder Theorem Calculator

Solve systems of congruences and see the combined solution modulo the product of the moduli.

Last updated: 2026-06-09T06:07:06.835Z

Enter integer remainders and positive integer moduli. Moduli must be pairwise coprime.

x ≡(mod)
x ≡(mod)
Solution
x ≡ 7
(mod 15)
Working
x ≡ 1 (mod 3)
Mi = 5, yi = 2, contribution = 10
x ≡ 2 (mod 5)
Mi = 3, yi = 2, contribution = 12
x = 1·5·2 + 2·3·2
All solutions: x = 7 + 15k, where k is any integer.

What is the Chinese Remainder Theorem?

The Chinese Remainder Theorem says that a system of congruences has a unique solution modulo the product of the moduli when the moduli are pairwise coprime.

This calculator builds that solution using modular inverses and the extended Euclidean algorithm.

How to use it

1

Enter each congruence

Type a remainder and a positive modulus for each line.

2

Keep the moduli coprime

If any pair of moduli shares a factor greater than 1, the standard CRT formula does not apply.

3

Read the combined solution

The result panel shows the smallest non-negative solution and the repeating solution family.

Worked example

x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7)

M = 3 × 5 × 7 = 105

The smallest solution is x = 23

All solutions are x = 23 + 105k

Frequently asked questions

What does pairwise coprime mean?

Every pair of moduli has greatest common divisor 1.

What if the moduli are not coprime?

The standard CRT formula may fail, and the system may have no solution.

Does the order matter?

No. Reordering the congruences does not change the final solution modulo M.

Why use modular inverses?

They let us isolate each congruence and combine the pieces into one solution.

Related Tools