Skip to content
100% local

Chinese remainder solver

Solve a system of congruences with the Chinese remainder theorem.

Input
Output

Chinese remainder solver

Paste a system of congruences — one per line, as "2 mod 3" or "x ≡ 2 (mod 3)" — and this tool finds the smallest non-negative x that satisfies all of them, using the Chinese remainder theorem. It is the standard way to recover a number from several remainder clues, and shows up in scheduling, checksum design, cryptography (RSA's CRT optimization), and puzzles phrased as "a number that leaves remainder a divided by n, and remainder b divided by m".

Moduli do not need to be pairwise coprime: the solver merges congruences two at a time with the extended Euclidean algorithm, and reports plainly when two of them conflict rather than guessing. "Show calculation steps" reveals every intermediate merge instead of only the final answer, and "Output format" switches between the full x ≡ r (mod n) notation and the bare value. "Support very large numbers" lifts the everyday size cap and uses exact BigInt arithmetic, so moduli with dozens of digits still resolve exactly; once a result is too long to read comfortably it switches to scientific notation, and "Scientific notation digits" sets how many significant digits that keeps.

Batch mode treats every input line as its own independent system: separate the congruences on a line with a semicolon, for example "2 mod 3; 3 mod 5; 2 mod 7", and get one result per line — handy for checking several small systems at once. A line that fails to parse, or has no solution, is reported next to that line without stopping the rest of the batch.

Everything runs locally in your browser — the numbers you paste are never uploaded anywhere. Copy the result, download it as a .txt file, or send the output straight back into the input to chain another step.

FAQ

What input format does it expect?
One congruence per line, written as "a mod n" or "x ≡ a (mod n)" — for example "2 mod 3". In batch mode, separate several congruences on one line with a semicolon to treat them as one independent system.
Do the moduli need to be coprime?
No. The solver merges any pair of moduli using their greatest common divisor, and reports "no solution" when two congruences genuinely conflict, rather than requiring pairwise-coprime input.
What happens if the system has no solution?
The tool names the congruence that conflicts with the earlier ones, instead of returning a wrong or partial answer.
How large can the numbers be?
By default moduli are kept to an everyday size. Turn on "Support very large numbers" to solve systems with much larger moduli using exact BigInt arithmetic; very long results are then shown in scientific notation.
Is my input uploaded anywhere?
No. The Chinese remainder theorem is solved entirely in your browser — your numbers never leave your device.