Chinese Remainder Theorem Calculator
Solve systems of congruences.
About this tool
Enter remainders and moduli to find the smallest x that satisfies every congruence. x ≡ 2 mod 3, x ≡ 3 mod 5 and x ≡ 2 mod 7 gives x = 23, Sunzi's classic puzzle.
How to use
How it works
When the moduli are pairwise coprime, the solution is unique modulo their product. Here 3 × 5 × 7 = 105, so every solution is 23 + 105k. The tool builds the answer from modular inverses.
x ≡ aᵢ (mod mᵢ) → x unique mod M = m₁m₂…mₖ
Worked example
Two congruences
- Input
- remainders 3, 4; moduli 5, 7
- Output
- 18
- Walkthrough
- 18 = 3×5 + 3 so 18 ≡ 3 mod 5, and 18 = 2×7 + 4 so 18 ≡ 4 mod 7. The moduli product is 35, so 18 is the smallest answer.
Limitations
- The moduli must be pairwise coprime. Moduli 4 and 6 return an error even if a solution exists.
- Give one remainder for each modulus.
Questions
What is x ≡ 2 (mod 3), 3 (mod 5), 2 (mod 7)?
What is x ≡ 3 (mod 5) and 4 (mod 7)?
Why does moduli 4 and 6 fail?
Features
- Any number of congruences
- Smallest non-negative solution
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Derivative as a concept
Khan Academy
When general calculators hand off to calculus tools.
Watch on YouTubeScientific notation examples
Khan Academy
Worked examples to compare with calculator output.
Watch on YouTube
- Percentages
Math is Fun
Percent of / percent change patterns for everyday calculators.
- Data Index
Math is Fun
Stats and probability explainers for data tools.