← All tools

Chinese Remainder Theorem Solver

Solve a system of simultaneous congruences x ≡ a₁ (mod m₁), x ≡ a₂ (mod m₂), … using the Chinese Remainder Theorem. Moduli need not be coprime — the generalised merge handles non-coprime moduli and reports when the system is inconsistent (has no solution). All arithmetic is exact (BigInt), so it works for cryptographically large numbers. Runs locally in your browser.

Congruences (one per line)

Solution

Each line is one congruence. Accepted formats: x ≡ 2 mod 3, 2 mod 3, 2 (mod 3), or just the two numbers 2 3 / 2,3 (residue first, modulus second). The solver merges congruences pairwise: to combine x ≡ r₁ (mod m₁) with x ≡ r₂ (mod m₂) it needs (r₂ − r₁) divisible by gcd(m₁, m₂); if not, the system is inconsistent. When solvable, the answer is the unique residue modulo lcm(m₁, m₂, …), shown as x ≡ r (mod M) with r in [0, M). Pairs with the Modular Arithmetic Calculator (single congruence) and GCD/LCM tools. Everything runs locally — nothing leaves your browser.