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
34716721301-2
1671312111-225
131112-225-27
1125125-27160
2120-27160-347
So our multiplicative inverse is 160 mod 347 ≡ 160
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
937574136301-1
57436312111-12
3632111152-12-3
2111521592-35
15259234-35-13
59341255-1318
342519-1318-31
2592718-3180
9712-3180-111
723180-111413
2120-111413-937
So our multiplicative inverse is 413 mod 937 ≡ 413
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4757340475010
7344751259101
475259121601-1
2592161431-12
2164351-12-11
4314302-11475
So our multiplicative inverse is -11 mod 475 ≡ 464
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 ≡ 676 × 167-1 (mod 347) ≡ 676 × 160 (mod 347) ≡ 243 (mod 347)
x ≡ 794 × 574-1 (mod 937) ≡ 794 × 413 (mod 937) ≡ 909 (mod 937)
x ≡ 865 × 734-1 (mod 475) ≡ 865 × 464 (mod 475) ≡ 460 (mod 475)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 347 × 937 × 475 = 154441025
  2. We calculate the numbers M1 to M3
    M1=M/m1=154441025/347=445075,   M2=M/m2=154441025/937=164825,   M3=M/m3=154441025/475=325139
  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
    3474450750347010
    4450753471282221101
    347221112601-1
    2211261951-12
    12695131-12-3
    9531322-311
    312151-311-168
    212011-168347
    So our multiplicative inverse is -168 mod 347 ≡ 179
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9371648250937010
    164825937175850101
    93785018701-1
    850879671-110
    8767120-110-11
    67203710-1143
    20726-1143-97
    761143-97140
    6160-97140-937
    So our multiplicative inverse is 140 mod 937 ≡ 140
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4753251390475010
    325139475684239101
    475239123601-1
    239236131-12
    2363782-12-157
    32112-157159
    2120-157159-475
    So our multiplicative inverse is 159 mod 475 ≡ 159
    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
    =  (243 × 445075 × 179 +
       909 × 164825 × 140 +
       460 × 325139 × 159)   mod 154441025
    = 22697860 (mod 154441025)


    So our answer is 22697860 (mod 154441025).


Verification

So we found that x ≡ 22697860
If this is correct, then the following statements (i.e. the original equations) are true:
167x (mod 347) ≡ 676 (mod 347)
574x (mod 937) ≡ 794 (mod 937)
734x (mod 475) ≡ 865 (mod 475)

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