Toolstia / Chinese remainder theorem calculator

Chinese remainder theorem calculator

The Chinese remainder theorem finds a number that leaves given remainders when divided by given moduli. Enter one congruence per line and get the smallest solution, the pattern of all solutions and a check of each line.

The Chinese remainder theorem finds a number that leaves given remainders when divided by given moduli. The moduli do not have to be coprime, but then a solution only exists if the congruences agree with each other. Write each line as 2 mod 3, or x = 2 (mod 3).

How it works

  1. Enter one congruence on each line, such as 2 mod 3.
  2. Read the smallest solution and how often it repeats.
  3. Use the check list to confirm each remainder.

Input form

Write each line as remainder and modulus. The forms 2 mod 3 and x = 2 (mod 3) both work, and the remainder may be negative.

Coprime or not

When the moduli share no factors a solution always exists. When they do, a solution exists only if the congruences agree, and the tool tells you if they do not.

All solutions

Once you have one solution, adding any multiple of the combined modulus gives another.

Big numbers

The tool uses exact big-number arithmetic, so results do not lose digits.

Questions

Is this uploaded anywhere?

Everything happens in your browser, and nothing you enter is sent anywhere.

What is the classic example?

x leaves 2 when divided by 3, 3 when divided by 5 and 2 when divided by 7. The smallest answer is 23 and it repeats every 105.

Why does it say no solution?

Two lines contradict each other. For example x = 1 mod 4 and x = 2 mod 6 cannot both be true, because the first is odd and the second is even.