Chinese Remainder Theorem Calculator
Solve simultaneous congruences when moduli are pairwise coprime. This educational calculator shows the formula, result, and step-by-step interpretation.
Calculator
What this calculator teaches
The Chinese Remainder Theorem combines modular conditions into one equivalent modular solution.
Use the result as a learning aid. For classwork, still show the formula and intermediate reasoning so the final answer is not just a black-box number.
How the Chinese Remainder Theorem Builds One Solution
The Chinese Remainder Theorem (CRT) replaces several compatible modular conditions with one repeating solution class. If the moduli m1, m2, ..., mn are pairwise coprime, there is exactly one solution modulo M = m1m2...mn. That means every integer satisfying all the congruences has the form x = x0 + kM for some integer k.
A constructive solution uses Mi = M/mi. Because Mi is coprime to mi, it has a modular inverse yi satisfying Miyi ≡ 1 (mod mi). The sum ΣaiMiyi is then reduced modulo M. Each term is designed to reproduce one desired remainder while becoming 0 modulo every other modulus.
| Step | Construction | Purpose |
|---|---|---|
| Combined modulus | M = ∏mᵢ | Sets the period of all solutions |
| Partial product | Mᵢ = M/mᵢ | Contains every modulus except mᵢ |
| Inverse | Mᵢyᵢ ≡ 1 (mod mᵢ) | Makes the ith term reproduce aᵢ |
Pairwise coprimality is the clean textbook case used by this calculator. More general systems with non-coprime moduli can sometimes have solutions, but they require an additional consistency test and are outside this page's stated method.
A reliable CRT check is computationally simple: reduce the candidate solution modulo every original modulus. This is often faster than repeating the constructive derivation. Also report the combined modulus, because “x ≡ 13 (mod 20)” communicates both the smallest nonnegative representative and the entire infinite family 13+20k.
When hand-solving, reduce large or negative remainders first. For example, x ≡ 17 (mod 5) can be rewritten as x ≡ 2 (mod 5), and x ≡ -1 (mod 7) can be rewritten as x ≡ 6 (mod 7). Equivalent residues do not change the solution set.
Formula & Symbols
| Concept | Formula or rule |
|---|---|
| Congruence | x ≡ aᵢ (mod mᵢ) |
| Solution modulus | M = m₁m₂...mₙ |
Worked example
Common mistakes
Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.
Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.
A CRT answer must satisfy every original remainder condition. Substitute the final x into each modulus before accepting it.
x = 23 is not the only integer solution to x ≡ 23 (mod 105); 128, 233, and all values 23 + 105k are equivalent solutions.
FAQ
Related calculators
These links will work after the calculators are registered in the final Math layout update.
Formula Explorer connections
Interpretation: This formula uses integer divisibility, modular arithmetic, finite fields or coding relationships. Assumption: Inputs are usually integers with specific modulus or coprimality requirements. Cryptographic examples are educational and not a substitute for vetted security libraries.