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
3328710332010
8713322207101
332207112501-1
2071251821-12
12582143-12-3
82431392-35
433914-35-8
394935-877
4311-877-85
313077-85332
So our multiplicative inverse is -85 mod 332 ≡ 247
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1676230167010
6231673122101
16712214501-1
122452321-13
4532113-13-4
3213263-411
13621-411-26
616011-26167
So our multiplicative inverse is -26 mod 167 ≡ 141
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2436136001-3
6160111-34
601600-34-243
So our multiplicative inverse is 4 mod 243 ≡ 4
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 ≡ 438 × 871-1 (mod 332) ≡ 438 × 247 (mod 332) ≡ 286 (mod 332)
x ≡ 601 × 623-1 (mod 167) ≡ 601 × 141 (mod 167) ≡ 72 (mod 167)
x ≡ 339 × 61-1 (mod 243) ≡ 339 × 4 (mod 243) ≡ 141 (mod 243)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 332 × 167 × 243 = 13472892
  2. We calculate the numbers M1 to M3
    M1=M/m1=13472892/332=40581,   M2=M/m2=13472892/167=80676,   M3=M/m3=13472892/243=55444
  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
    332405810332010
    4058133212277101
    3327742401-4
    7724351-413
    24544-413-56
    541113-5669
    4140-5669-332
    So our multiplicative inverse is 69 mod 332 ≡ 69
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    167806760167010
    8067616748315101
    1671511201-11
    152711-1178
    2120-1178-167
    So our multiplicative inverse is 78 mod 167 ≡ 78
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    243554440243010
    5544424322840101
    243406301-6
    4031311-679
    3130-679-243
    So our multiplicative inverse is 79 mod 243 ≡ 79
    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
    =  (286 × 40581 × 69 +
       72 × 80676 × 78 +
       141 × 55444 × 79)   mod 13472892
    = 12233490 (mod 13472892)


    So our answer is 12233490 (mod 13472892).


Verification

So we found that x ≡ 12233490
If this is correct, then the following statements (i.e. the original equations) are true:
871x (mod 332) ≡ 438 (mod 332)
623x (mod 167) ≡ 601 (mod 167)
61x (mod 243) ≡ 339 (mod 243)

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