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
87716754201-5
167423411-516
424111-516-21
41141016-21877
So our multiplicative inverse is -21 mod 877 ≡ 856
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2369810236010
981236437101
2363761401-6
3714291-613
14915-613-19
951413-1932
5411-1932-51
414032-51236
So our multiplicative inverse is -51 mod 236 ≡ 185
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1618500161010
850161545101
1614532601-3
45261191-34
261917-34-7
197254-718
7512-718-25
522118-2568
2120-2568-161
So our multiplicative inverse is 68 mod 161 ≡ 68
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 ≡ 541 × 167-1 (mod 877) ≡ 541 × 856 (mod 877) ≡ 40 (mod 877)
x ≡ 789 × 981-1 (mod 236) ≡ 789 × 185 (mod 236) ≡ 117 (mod 236)
x ≡ 502 × 850-1 (mod 161) ≡ 502 × 68 (mod 161) ≡ 4 (mod 161)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 877 × 236 × 161 = 33322492
  2. We calculate the numbers M1 to M3
    M1=M/m1=33322492/877=37996,   M2=M/m2=33322492/236=141197,   M3=M/m3=33322492/161=206972
  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
    877379960877010
    3799687743285101
    87728532201-3
    2852212211-337
    222111-337-40
    21121037-40877
    So our multiplicative inverse is -40 mod 877 ≡ 837
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2361411970236010
    14119723659869101
    2366932901-3
    69292111-37
    291127-37-17
    117147-1724
    7413-1724-41
    431124-4165
    3130-4165-236
    So our multiplicative inverse is 65 mod 236 ≡ 65
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1612069720161010
    206972161128587101
    1618717401-1
    87741131-12
    741359-12-11
    139142-1113
    9421-1113-37
    414013-37161
    So our multiplicative inverse is -37 mod 161 ≡ 124
    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
    =  (40 × 37996 × 837 +
       117 × 141197 × 65 +
       4 × 206972 × 124)   mod 33322492
    = 16025461 (mod 33322492)


    So our answer is 16025461 (mod 33322492).


Verification

So we found that x ≡ 16025461
If this is correct, then the following statements (i.e. the original equations) are true:
167x (mod 877) ≡ 541 (mod 877)
981x (mod 236) ≡ 789 (mod 236)
850x (mod 161) ≡ 502 (mod 161)

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