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
68350133301-13
50331171-1314
3317116-1314-27
17161114-2741
161160-2741-683
So our multiplicative inverse is 41 mod 683 ≡ 41
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1994100199010
410199212101
1991216701-16
127151-1617
7512-1617-33
522117-3383
2120-3383-199
So our multiplicative inverse is 83 mod 199 ≡ 83
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
947364221901-2
36421911451-23
219145174-23-5
145741713-58
747113-58-13
7132328-13307
3211-13307-320
2120307-320947
So our multiplicative inverse is -320 mod 947 ≡ 627
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 ≡ 842 × 50-1 (mod 683) ≡ 842 × 41 (mod 683) ≡ 372 (mod 683)
x ≡ 39 × 410-1 (mod 199) ≡ 39 × 83 (mod 199) ≡ 53 (mod 199)
x ≡ 121 × 364-1 (mod 947) ≡ 121 × 627 (mod 947) ≡ 107 (mod 947)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 683 × 199 × 947 = 128713399
  2. We calculate the numbers M1 to M3
    M1=M/m1=128713399/683=188453,   M2=M/m2=128713399/199=646801,   M3=M/m3=128713399/947=135917
  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
    6831884530683010
    188453683275628101
    68362815501-1
    6285511231-112
    552329-112-25
    2392512-2562
    9514-2562-87
    541162-87149
    4140-87149-683
    So our multiplicative inverse is 149 mod 683 ≡ 149
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1996468010199010
    646801199325051101
    1995134601-3
    5146151-34
    46591-34-39
    51504-39199
    So our multiplicative inverse is -39 mod 199 ≡ 160
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9471359170947010
    135917947143496101
    947496145101-1
    4964511451-12
    45145101-12-21
    4514502-21947
    So our multiplicative inverse is -21 mod 947 ≡ 926
    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
    =  (372 × 188453 × 149 +
       53 × 646801 × 160 +
       107 × 135917 × 926)   mod 128713399
    = 50718586 (mod 128713399)


    So our answer is 50718586 (mod 128713399).


Verification

So we found that x ≡ 50718586
If this is correct, then the following statements (i.e. the original equations) are true:
50x (mod 683) ≡ 842 (mod 683)
410x (mod 199) ≡ 39 (mod 199)
364x (mod 947) ≡ 121 (mod 947)

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