Chinese Remainder Theorem Calculator

Enter a system of congruences and get the solution with every step shown - modulus, inverses, and a check by substitution.

Your congruences (x ≡ remainder mod modulus)

- solution x (smallest ≥ 0)
- combined modulus M

Runs entirely on your device - nothing is ever uploaded.

More tools

How to use the CRT calculator

  1. Type each congruence as a remainder and a modulus (modulus at least 2).
  2. Add up to six congruences, or press Load example for the classic 3-5-7 system.
  3. Read the solution x and the combined modulus M - the answer updates as you type.
  4. Follow the numbered steps to see the modulus split, the inverses, and the substitution check.

What the colors mean

Each congruence owns one color, shown as the dot on its row. Every number derived from that equation - its M piece, its modular inverse, its term in the final sum, and its verification line - wears the same color. Black would leave you hunting through subscripts; the color code lets you trace each equation from input to answer at a glance.

Worked example

For x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7): M = 3 × 5 × 7 = 105. The pieces are M₁ = 35, M₂ = 21, M₃ = 15 with inverses y₁ = 2, y₂ = 1, y₃ = 1. Then x = (2·35·2 + 3·21·1 + 2·15·1) mod 105 = 233 mod 105 = 23, so x ≡ 23 (mod 105).

When there is no solution

With non-coprime moduli a system can contradict itself - for example x ≡ 1 (mod 2) and x ≡ 2 (mod 4), where one demands an odd number and the other an even one. The calculator reports exactly which equations clash and why, instead of a bare error.