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
85739027701-2
39077551-211
775152-211-167
522111-167345
2120-167345-857
So our multiplicative inverse is 345 mod 857 ≡ 345
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
269525901-5
529571-526
9712-526-31
723126-31119
2120-31119-269
So our multiplicative inverse is 119 mod 269 ≡ 119
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3395063901-6
50391111-67
391136-67-27
116157-2734
6511-2734-61
515034-61339
So our multiplicative inverse is -61 mod 339 ≡ 278
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 ≡ 38 × 390-1 (mod 857) ≡ 38 × 345 (mod 857) ≡ 255 (mod 857)
x ≡ 255 × 52-1 (mod 269) ≡ 255 × 119 (mod 269) ≡ 217 (mod 269)
x ≡ 231 × 50-1 (mod 339) ≡ 231 × 278 (mod 339) ≡ 147 (mod 339)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 857 × 269 × 339 = 78150687
  2. We calculate the numbers M1 to M3
    M1=M/m1=78150687/857=91191,   M2=M/m2=78150687/269=290523,   M3=M/m3=78150687/339=230533
  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
    857911910857010
    91191857106349101
    857349215901-2
    3491592311-25
    1593154-25-27
    314735-27194
    4311-27194-221
    3130194-221857
    So our multiplicative inverse is -221 mod 857 ≡ 636
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2692905230269010
    29052326910803101
    269389201-89
    32111-8990
    2120-8990-269
    So our multiplicative inverse is 90 mod 269 ≡ 90
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3392305330339010
    23053333968013101
    3391326101-26
    1311301-26339
    So our multiplicative inverse is -26 mod 339 ≡ 313
    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
    =  (255 × 91191 × 636 +
       217 × 290523 × 90 +
       147 × 230533 × 313)   mod 78150687
    = 44501694 (mod 78150687)


    So our answer is 44501694 (mod 78150687).


Verification

So we found that x ≡ 44501694
If this is correct, then the following statements (i.e. the original equations) are true:
390x (mod 857) ≡ 38 (mod 857)
52x (mod 269) ≡ 255 (mod 269)
50x (mod 339) ≡ 231 (mod 339)

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