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
81137725701-2
377576351-213
5735122-213-15
352211313-1528
221319-1528-43
1391428-4371
9421-4371-185
414071-185811
So our multiplicative inverse is -185 mod 811 ≡ 626
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
699560113901-1
560139441-15
1394343-15-171
43115-171176
3130-171176-699
So our multiplicative inverse is 176 mod 699 ≡ 176
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
96131332201-3
313221451-343
22542-343-175
522143-175393
2120-175393-961
So our multiplicative inverse is 393 mod 961 ≡ 393
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 ≡ 213 × 377-1 (mod 811) ≡ 213 × 626 (mod 811) ≡ 334 (mod 811)
x ≡ 33 × 560-1 (mod 699) ≡ 33 × 176 (mod 699) ≡ 216 (mod 699)
x ≡ 618 × 313-1 (mod 961) ≡ 618 × 393 (mod 961) ≡ 702 (mod 961)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 811 × 699 × 961 = 544780329
  2. We calculate the numbers M1 to M3
    M1=M/m1=544780329/811=671739,   M2=M/m2=544780329/699=779371,   M3=M/m3=544780329/961=566889
  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
    8116717390811010
    671739811828231101
    811231311801-3
    23111811131-34
    11811315-34-7
    11352234-7158
    5312-7158-165
    3211158-165323
    2120-165323-811
    So our multiplicative inverse is 323 mod 811 ≡ 323
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6997793710699010
    7793716991114685101
    69968511401-1
    6851448131-149
    141311-149-50
    13113049-50699
    So our multiplicative inverse is -50 mod 699 ≡ 649
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9615668890961010
    566889961589860101
    961860110101-1
    8601018521-19
    10152149-19-10
    5249139-1019
    493161-1019-314
    313019-314961
    So our multiplicative inverse is -314 mod 961 ≡ 647
    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
    =  (334 × 671739 × 323 +
       216 × 779371 × 649 +
       702 × 566889 × 647)   mod 544780329
    = 108528354 (mod 544780329)


    So our answer is 108528354 (mod 544780329).


Verification

So we found that x ≡ 108528354
If this is correct, then the following statements (i.e. the original equations) are true:
377x (mod 811) ≡ 213 (mod 811)
560x (mod 699) ≡ 33 (mod 699)
313x (mod 961) ≡ 618 (mod 961)

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