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
65356219101-1
562916161-17
9116511-17-36
1611157-3643
11521-3643-122
515043-122653
So our multiplicative inverse is -122 mod 653 ≡ 531
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
79760131701-13
6017391-1340
17918-1340-53
981140-5393
8180-5393-797
So our multiplicative inverse is 93 mod 797 ≡ 93
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3197750319010
7753192137101
31913724501-2
13745321-27
452221-27-156
21207-156319
So our multiplicative inverse is -156 mod 319 ≡ 163
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 ≡ 992 × 562-1 (mod 653) ≡ 992 × 531 (mod 653) ≡ 434 (mod 653)
x ≡ 527 × 60-1 (mod 797) ≡ 527 × 93 (mod 797) ≡ 394 (mod 797)
x ≡ 456 × 775-1 (mod 319) ≡ 456 × 163 (mod 319) ≡ 1 (mod 319)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 653 × 797 × 319 = 166020679
  2. We calculate the numbers M1 to M3
    M1=M/m1=166020679/653=254243,   M2=M/m2=166020679/797=208307,   M3=M/m3=166020679/319=520441
  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
    6532542430653010
    254243653389226101
    653226220101-2
    2262011251-23
    2012581-23-26
    2512503-26653
    So our multiplicative inverse is -26 mod 653 ≡ 627
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7972083070797010
    208307797261290101
    797290221701-2
    2902171731-23
    21773271-23-8
    7371123-811
    712351-811-393
    212011-393797
    So our multiplicative inverse is -393 mod 797 ≡ 404
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3195204410319010
    5204413191631152101
    31915221501-2
    152151021-221
    15271-221-149
    212021-149319
    So our multiplicative inverse is -149 mod 319 ≡ 170
    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
    =  (434 × 254243 × 627 +
       394 × 208307 × 404 +
       1 × 520441 × 170)   mod 166020679
    = 161308412 (mod 166020679)


    So our answer is 161308412 (mod 166020679).


Verification

So we found that x ≡ 161308412
If this is correct, then the following statements (i.e. the original equations) are true:
562x (mod 653) ≡ 992 (mod 653)
60x (mod 797) ≡ 527 (mod 797)
775x (mod 319) ≡ 456 (mod 319)

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