Files never leave your device

Chinese remainder theorem calculator

Solve simultaneous integer congruences and combine their moduli. Your inputs stay on your device.

Set up your task

Ready. Processing stays in this browser.

How to use Chinese remainder theorem calculator

Solve simultaneous integer congruences and combine their moduli. The pre-filled problem gives you a worked starting point. Compare the response with your own working before trying the self-check below.

  1. Check the example inputs: Remainder and modulus (one pair per line).
  2. Change the inputs for your problem. Results update as you type, so finish entering the values before copying an answer.
  3. Use the working to check an intermediate value or assumption. Then change the example as suggested in the self-check and compare the result.

Supported inputs and limits

Enter 2 to 8 rows, each with remainder followed by modulus. Moduli must be at least 2. Compatible non-coprime systems work too.

How it works

A congruence fixes a remainder without fixing the original integer. The Chinese remainder theorem combines these constraints into a single periodic solution. When the moduli are pairwise coprime, the solutions repeat at their product. More generally the period is the least common multiple of the moduli.

The calculator merges the congruences in input order. The difference between two remainders must be divisible by the moduli’s greatest common divisor. When this holds, an extended Euclidean step identifies the required adjustment and the result is normalised to the smallest non-negative representative.

Example

Run the pre-filled example. Its first result is “x ≡ 23 (mod 105)”.

Remainder and modulus (one pair per line)
2 3
3 5
2 7
x ≡ 23 (mod 105)
Combined: x ≡ 2 (mod 3)
Combined: x ≡ 8 (mod 15)
Combined: x ≡ 23 (mod 105)

Questions about Chinese remainder theorem calculator

Can a remainder be negative?

Yes. The combined answer is reported as a non-negative representative of the same congruence class.

Can moduli share a factor?

Yes, if the remainders are compatible modulo the common factor. Two conflicting residues imply there is no solution.

Try x ≡ 2 mod 4 and x ≡ 6 mod 8.

The answer is x ≡ 6 mod 8. Every integer with remainder 6 modulo 8 also has remainder 2 modulo 4.

Related tools

Year 2: Algorithms and theory

Last updated