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
1541670154010
167154113101
15413111101-11
1311121-1112
11251-1112-71
212012-71154
So our multiplicative inverse is -71 mod 154 ≡ 83
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
75123734001-3
237405371-316
403713-316-19
37312116-19244
3130-19244-751
So our multiplicative inverse is 244 mod 751 ≡ 244
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3479300347010
9303472236101
347236111101-1
2361112141-13
11114713-13-22
1413113-2225
131130-2225-347
So our multiplicative inverse is 25 mod 347 ≡ 25
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 ≡ 492 × 167-1 (mod 154) ≡ 492 × 83 (mod 154) ≡ 26 (mod 154)
x ≡ 401 × 237-1 (mod 751) ≡ 401 × 244 (mod 751) ≡ 214 (mod 751)
x ≡ 32 × 930-1 (mod 347) ≡ 32 × 25 (mod 347) ≡ 106 (mod 347)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 154 × 751 × 347 = 40131938
  2. We calculate the numbers M1 to M3
    M1=M/m1=40131938/154=260597,   M2=M/m2=40131938/751=53438,   M3=M/m3=40131938/347=115654
  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
    1542605970154010
    260597154169229101
    154295901-5
    299321-516
    9241-516-69
    212016-69154
    So our multiplicative inverse is -69 mod 154 ≡ 85
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    751534380751010
    5343875171117101
    75111764901-6
    117492191-613
    4919211-613-32
    19111813-3245
    11813-3245-77
    832245-77199
    3211-77199-276
    2120199-276751
    So our multiplicative inverse is -276 mod 751 ≡ 475
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3471156540347010
    115654347333103101
    34710333801-3
    103382271-37
    3827111-37-10
    2711257-1027
    11521-1027-64
    515027-64347
    So our multiplicative inverse is -64 mod 347 ≡ 283
    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
    =  (26 × 260597 × 85 +
       214 × 53438 × 475 +
       106 × 115654 × 283)   mod 40131938
    = 6143394 (mod 40131938)


    So our answer is 6143394 (mod 40131938).


Verification

So we found that x ≡ 6143394
If this is correct, then the following statements (i.e. the original equations) are true:
167x (mod 154) ≡ 492 (mod 154)
237x (mod 751) ≡ 401 (mod 751)
930x (mod 347) ≡ 32 (mod 347)

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