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
4976081701-8
6017391-825
17918-825-33
981125-3358
8180-3358-497
So our multiplicative inverse is 58 mod 497 ≡ 58
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2224270222010
4272221205101
22220511701-1
205171211-113
171170-113-222
So our multiplicative inverse is 13 mod 222 ≡ 13
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
769395137401-1
3953741211-12
374211717-12-35
2117142-3537
17441-3537-183
414037-183769
So our multiplicative inverse is -183 mod 769 ≡ 586
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 ≡ 976 × 60-1 (mod 497) ≡ 976 × 58 (mod 497) ≡ 447 (mod 497)
x ≡ 704 × 427-1 (mod 222) ≡ 704 × 13 (mod 222) ≡ 50 (mod 222)
x ≡ 921 × 395-1 (mod 769) ≡ 921 × 586 (mod 769) ≡ 637 (mod 769)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 497 × 222 × 769 = 84846846
  2. We calculate the numbers M1 to M3
    M1=M/m1=84846846/497=170718,   M2=M/m2=84846846/222=382193,   M3=M/m3=84846846/769=110334
  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
    4971707180497010
    170718497343247101
    4972472301-2
    24738211-2165
    3130-2165-497
    So our multiplicative inverse is 165 mod 497 ≡ 165
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2223821930222010
    3821932221721131101
    22213119101-1
    131911401-12
    9140211-12-5
    4011372-517
    11714-517-22
    741317-2239
    4311-2239-61
    313039-61222
    So our multiplicative inverse is -61 mod 222 ≡ 161
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7691103340769010
    110334769143367101
    76936723501-2
    3673510171-221
    351721-221-44
    17117021-44769
    So our multiplicative inverse is -44 mod 769 ≡ 725
    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
    =  (447 × 170718 × 165 +
       50 × 382193 × 161 +
       637 × 110334 × 725)   mod 84846846
    = 18185180 (mod 84846846)


    So our answer is 18185180 (mod 84846846).


Verification

So we found that x ≡ 18185180
If this is correct, then the following statements (i.e. the original equations) are true:
60x (mod 497) ≡ 976 (mod 497)
427x (mod 222) ≡ 704 (mod 222)
395x (mod 769) ≡ 921 (mod 769)

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