Bootstrap
  C.R.T. .com
It doesn't have to be difficult if someone just explains it right.

Welcome to ChineseRemainderTheorem.com!

×

Modal Header

Some text in the Modal Body

Some other text...

Use the calculator below to get a step-by-step calculation of the Chinese Remainder Theory. Just enter the numbers you would like and press "Calculate" .


This removes all numbers from the textboxes, such that you can fill in your own.

This fills all textboxes with random numbers. If you fill in random numbers yourself, it is very likely that those numbers do not have a solution. To avoid disappointment, use this button instead! It only uses random numbers that do have a solution.

This button is similar to the "Clear everything" button, but only clears the left column.
This is useful if you want your equations to be of the form x ≡ a (mod m) rather than bx ≡ a (mod m).
In that case, it can be especially useful after using the random numbers button.

Do you want to use more equations? Go ahead and use this button. It adds another row that you can fill in. Not sure what numbers to put in this newly added row? Use the random numbers button again!

Do you have too many rows? Use one of these buttons to remove a row. You can always add a row again using the yellow "Add a row" button.

Are you ready to view a full step-by-step Chinese Remainder Theorem calculation for the numbers you have entered? Then use this button!

Want to know more?


Transform the equations

You used one or more of the fields on the left, so your equations are of the form bx ≡ a mod m.
We want them to be of the form x ≡ a mod m, so we need to move the values on the left to the right side of the equation.
For a more detailed explanation about how this works, see this part of our page about how to execute the Chinese Remainder algorithm.

First, we calculate the inverses of the leftmost value on each row:

nbqr t1t2t3
57265057010
26557437101
573712001-1
37201171-12
201713-12-3
173522-317
3211-317-20
212017-2057
So our multiplicative inverse is -20 mod 57 ≡ 37
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3859690385010
9693852199101
385199118601-1
1991861131-12
18613144-12-29
134312-2989
4140-2989-385
So our multiplicative inverse is 89 mod 385 ≡ 89
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7098280709010
8287091119101
709119511401-5
119114151-56
1145224-56-137
54116-137143
4140-137143-709
So our multiplicative inverse is 143 mod 709 ≡ 143
Source: ExtendedEuclideanAlgorithm.com

Click on any row to reveal a more detailed calculation of each multiplicative inverse.

Now that we now the inverses, let's move the leftmost value on each row to the right of the equation:

x ≡ 613 × 265-1 (mod 57) ≡ 613 × 37 (mod 57) ≡ 52 (mod 57)
x ≡ 980 × 969-1 (mod 385) ≡ 980 × 89 (mod 385) ≡ 210 (mod 385)
x ≡ 829 × 828-1 (mod 709) ≡ 829 × 143 (mod 709) ≡ 144 (mod 709)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 57 × 385 × 709 = 15559005
  2. We calculate the numbers M1 to M3
    M1=M/m1=15559005/57=272965,   M2=M/m2=15559005/385=40413,   M3=M/m3=15559005/709=21945
  3. We now calculate the modular multiplicative inverses M1-1 to M3-1
    Have a look at the page that explains how to calculate modular multiplicative inverse.
    Using, for example, the Extended Euclidean Algorithm, we will find that:

    nbqr t1t2t3
    57272965057010
    27296557478849101
    57491801-1
    498611-17
    8180-17-57
    So our multiplicative inverse is 7 mod 57 ≡ 7
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    385404130385010
    40413385104373101
    38537311201-1
    373123111-132
    121120-132-385
    So our multiplicative inverse is 32 mod 385 ≡ 32
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    709219450709010
    2194570930675101
    70967513401-1
    6753419291-120
    342915-120-21
    2955420-21125
    5411-21125-146
    4140125-146709
    So our multiplicative inverse is -146 mod 709 ≡ 563
    Source: ExtendedEuclideanAlgorithm.com
  4. Now we can calculate x with the equation we saw earlier
    x = (a1 × M1 × M1-1   +   a2 × M2 × M2-1   + ... +   ak × Mk × Mk-1)   mod M
    =  (52 × 272965 × 7 +
       210 × 40413 × 32 +
       144 × 21945 × 563)   mod 15559005
    = 2916970 (mod 15559005)


    So our answer is 2916970 (mod 15559005).


Verification

So we found that x ≡ 2916970
If this is correct, then the following statements (i.e. the original equations) are true:
265x (mod 57) ≡ 613 (mod 57)
969x (mod 385) ≡ 980 (mod 385)
828x (mod 709) ≡ 829 (mod 709)

Let's see whether that's indeed the case if we use x ≡ 2916970.