Math

Chinese Remainder Theorem Calculator

Solve two integer congruences, including compatible congruences whose moduli share factors.

Exact method explained belowEditable inputs
Calculation notebook
Calculation notebook

The formula and worked example below explain the calculation.

See the method

Enter your values

Runs on your device

Your answer

Your result

Let’s calculate.

Use the Calculate button to see your result.

Review the method below for assumptions and conventions.

How to use this tool

  1. Enter first remainder, first modulus, second remainder, second modulus.
  2. Select Calculate to view the result.
  3. Check the method and assumptions below before using the result.

The method, explained

Let g=gcd(m,n). A solution exists when b−a is divisible by g. Solve the reduced congruence using an extended-Euclidean coefficient and normalize modulo lcm(m,n).

A WORKED EXAMPLE

Using first remainder = 2, first modulus = 3, second remainder = 3, second modulus = 5, the result is x ≡ 8 (mod 15). Change these example inputs to match your task; use the method above to check each step.

Understanding your result

No. This version checks compatibility for shared factors. For example x ≡ 1 mod 4 and x ≡ 3 mod 6 have solutions despite gcd(4,6)=2.

What to keep in mind

Two congruences only, up to 200 digits per input. Finite-precision arithmetic is used. Check the domain and the stated convention before using an approximation.

Common questions

Must the moduli be relatively prime?

No. This version checks compatibility for shared factors. For example x ≡ 1 mod 4 and x ≡ 3 mod 6 have solutions despite gcd(4,6)=2.

How can I check the result?

Let g=gcd(m,n). A solution exists when b−a is divisible by g. Solve the reduced congruence using an extended-Euclidean coefficient and normalize modulo lcm(m,n). The worked example uses editable inputs. Calculations run on your device; no external API or account is required.

Methodology maintained by ClarityKit. How these tools are built and checked.