Chinese Remainder Theorem Calculator

Solve three simultaneous congruences with pairwise coprime moduli.

Solve a Congruence System
Enter each integer remainder beside its positive modulus.

About the Chinese Remainder Theorem Calculator

The Chinese Remainder Theorem, often abbreviated CRT, combines several modular conditions into one solution. A congruence such as x ≡ 2 modulo 3 means that dividing x by 3 leaves remainder 2. This calculator accepts three such equations and finds the smallest nonnegative integer satisfying all of them simultaneously. The classical theorem applies when the moduli are pairwise coprime, meaning every pair has greatest common divisor one. Under that condition there is exactly one solution modulo the product of the moduli. For moduli 3, 5, and 7, the product is 105. If the smallest solution is 23, then 23, 128, 233, and every number obtained by adding or subtracting 105 satisfy the same system. The constructive algorithm begins by multiplying all moduli to form M. For each equation, it divides M by that equation's modulus to form a partial product. Because the moduli are pairwise coprime, the partial product has a modular multiplicative inverse relative to the omitted modulus. Multiplying each remainder, partial product, and inverse creates a term that matches one congruence while contributing zero to the others. Adding the terms and reducing modulo M yields the answer. CRT has applications far beyond textbook number theory. It supports efficient large-integer arithmetic, cryptographic implementations, coding theory, calendar cycles, rotating schedules, computer algebra, and the reconstruction of values from residues. It is particularly useful when a difficult calculation can be split into smaller independent calculations modulo several numbers and recombined afterward. Enter integer remainders and moduli greater than one. A remainder may be negative or larger than its modulus because reduction normalizes it automatically. This version intentionally requires pairwise coprime moduli, matching the standard theorem and guaranteeing a unique residue class. Systems with noncoprime moduli can sometimes be solved, but they require an additional compatibility check and are outside this calculator's scope. Always verify a result by dividing it by each modulus and checking the resulting remainder.

Chinese Remainder Theorem Examples

Each row combines three congruences into one residue class.

CongruencesSolutionExplanation
2 mod 3; 3 mod 5; 2 mod 723 mod 105Twenty-three leaves the requested three remainders.
1 mod 4; 2 mod 5; 3 mod 717 mod 140The pairwise coprime moduli multiply to 140.
0 mod 2; 1 mod 3; 4 mod 54 mod 30Four is the smallest nonnegative simultaneous solution.

How to Solve Congruences

  1. Enter the integer remainder and modulus for the first congruence.
  2. Enter the second and third remainder-modulus pairs.
  3. Confirm that every pair of moduli has greatest common divisor one.
  4. Select Solve Congruences to find the unique residue class.
  5. Verify the answer by reducing it modulo each entered modulus.

Chinese Remainder Theorem FAQ

What does pairwise coprime mean?

Every distinct pair of moduli must have greatest common divisor one. The moduli themselves do not need to be prime numbers.

Why are there infinitely many solutions?

The theorem identifies one residue class modulo the product of all moduli. Adding any multiple of that product preserves every remainder.

Can a remainder be larger than its modulus?

Yes, it will reduce to an equivalent standard remainder. For example, remainder eight modulo five is equivalent to remainder three.

Can the theorem use negative remainders?

Yes, negative remainders represent valid residue classes and can be normalized. The displayed answer is the smallest nonnegative representative.

What happens when moduli are not coprime?

A solution may exist only when overlapping congruences are compatible. This calculator follows the classical pairwise-coprime theorem and reports those systems as unsupported.

How can I verify the CRT solution?

Divide the displayed solution by each modulus and inspect the remainder. Each remainder should match the corresponding input after modular reduction.