Chinese Remainder Theorem Calculator

Solve a system of congruences x ≡ r (mod m) and get the smallest solution and combined modulus.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open Chinese Remainder Theorem Calculator and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What Chinese Remainder Theorem Calculator does

    Solve a system of congruences x ≡ r (mod m) and get the smallest solution and combined modulus.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Enter one congruence per line as remainder, modulus (for example 2, 3 for x ≡ 2 mod 3), from 2 to 12 lines. The calculator solves the whole system, even when the moduli are not coprime, and gives the smallest non-negative x, the combined modulus and a check of every equation.

Method

The congruences are merged two at a time. For coprime moduli a unique solution modulo the product always exists. For moduli that share factors, a solution exists only if the remainders agree on the common part; otherwise the tool reports that the system is inconsistent.

Exact

Big-integer arithmetic is used, so the answer is exact. Whole numbers of any size are accepted (exact big-integer arithmetic).

Worked example

x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7) gives x = 23 modulo 105 (Sun Tzu's classic puzzle).

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

What if the moduli share a factor?

A solution may or may not exist; the tool checks and says so.

Is the answer unique?

Unique modulo the combined modulus (the lcm).

How do I enter the equations?

One per line: remainder, comma, modulus.

How many equations?

From 2 to 12.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages