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
5219350521010
9355211414101
521414110701-1
4141073931-14
10793114-14-5
9314694-534
14915-534-39
951434-3973
5411-3973-112
414073-112521
So our multiplicative inverse is -112 mod 521 ≡ 409
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
913629128401-1
6292842611-13
28461440-13-13
61401213-1316
4021119-1316-29
21191216-2945
19291-2945-434
212045-434913
So our multiplicative inverse is -434 mod 913 ≡ 479
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4327130432010
7134321281101
432281115101-1
28115111301-12
151130121-12-3
13021642-320
21451-320-103
414020-103432
So our multiplicative inverse is -103 mod 432 ≡ 329
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 ≡ 748 × 935-1 (mod 521) ≡ 748 × 409 (mod 521) ≡ 105 (mod 521)
x ≡ 647 × 629-1 (mod 913) ≡ 647 × 479 (mod 913) ≡ 406 (mod 913)
x ≡ 878 × 713-1 (mod 432) ≡ 878 × 329 (mod 432) ≡ 286 (mod 432)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 521 × 913 × 432 = 205490736
  2. We calculate the numbers M1 to M3
    M1=M/m1=205490736/521=394416,   M2=M/m2=205490736/913=225072,   M3=M/m3=205490736/432=475673
  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
    5213944160521010
    39441652175719101
    5211927801-27
    198231-2755
    8322-2755-137
    321155-137192
    2120-137192-521
    So our multiplicative inverse is 192 mod 521 ≡ 192
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9132250720913010
    225072913246474101
    913474143901-1
    4744391351-12
    439351219-12-25
    35191162-2527
    191613-2527-52
    1635127-52287
    3130-52287-913
    So our multiplicative inverse is 287 mod 913 ≡ 287
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4324756730432010
    475673432110141101
    43241102201-10
    41221191-1011
    221913-1011-21
    1936111-21137
    3130-21137-432
    So our multiplicative inverse is 137 mod 432 ≡ 137
    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
    =  (105 × 394416 × 192 +
       406 × 225072 × 287 +
       286 × 475673 × 137)   mod 205490736
    = 3966478 (mod 205490736)


    So our answer is 3966478 (mod 205490736).


Verification

So we found that x ≡ 3966478
If this is correct, then the following statements (i.e. the original equations) are true:
935x (mod 521) ≡ 748 (mod 521)
629x (mod 913) ≡ 647 (mod 913)
713x (mod 432) ≡ 878 (mod 432)

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