Skip to main content

Chinese Remainder Theorem Solver

Combine modular congruences into one exact solution and modulus with a browser-based CRT solver.

Solve a congruence system

Example input: `x ≡ 2 (mod 3)` on one line and `x ≡ 3 (mod 5)` on the next.

Result

-

Combined modulus

-

How to use this tool

A quick workflow so you can get the result you need without guesswork.

  1. 1

    Enter one congruence per line using the format `x ≡ a (mod n)` or simply `a mod n`.

  2. 2

    Click Solve System to combine the congruences into a single solution.

  3. 3

    Review the smallest non-negative solution and the combined modulus if the system is consistent.

Useful examples

Practical cases where this utility saves time and reduces mistakes.

Number theory coursework

Check CRT homework problems and verify hand-computed modular arithmetic results.

Algorithm prototyping

Test modular systems when working on scheduling, cryptography exercises, or integer reconstruction tasks.

Math contest prep

Quickly validate congruence systems and compare multiple approaches to the same CRT problem.

Frequently asked questions

Short answers to the most common questions about the calculator above.

What input format does the CRT solver accept?

You can enter each line as `x ≡ 2 (mod 5)`, `x = 2 mod 5`, or simply `2 mod 5`. The solver extracts the residue and modulus from each line.

Does the solver require pairwise coprime moduli?

No. It can solve compatible systems even when the moduli are not pairwise coprime, as long as the congruences are consistent.

What happens if the system is inconsistent?

The solver reports that no solution exists when two congruences conflict and cannot be merged.

Why is the answer given modulo a combined modulus?

All solutions repeat after the least combined modulus returned by the CRT merge process, so the result is naturally expressed modulo that value.

Solve Modular Congruence Systems with the Chinese Remainder Theorem

This Chinese remainder theorem solver combines multiple congruences into a single solution of the form x ≡ a (mod n). It accepts simple line-based input, computes the merged modulus, and returns the smallest non-negative solution whenever the system is consistent.

That makes it useful for students, contest participants, and developers working with modular arithmetic. The calculation is done locally in the browser using exact integer arithmetic, so you can test systems quickly and reliably.

Useful for Number Theory, Cryptography, and Algorithm Work

CRT shows up in many contexts, from introductory number theory to cryptographic exercises and residue reconstruction problems. A dedicated solver helps you move faster when you need to verify a result or explore how congruences combine.

This page also handles consistent systems with non-coprime moduli, which is important when you want a more general modular arithmetic helper rather than a narrow textbook-only implementation.