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
439323111601-1
3231162911-13
11691125-13-4
91253163-415
251619-415-19
1691715-1934
9712-1934-53
723134-53193
2120-53193-439
So our multiplicative inverse is 193 mod 439 ≡ 193
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6384913101-13
4914901-13638
So our multiplicative inverse is -13 mod 638 ≡ 625
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2173030217010
303217186101
2178624501-2
86451411-23
454114-23-5
4141013-553
4140-553-217
So our multiplicative inverse is 53 mod 217 ≡ 53
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 ≡ 357 × 323-1 (mod 439) ≡ 357 × 193 (mod 439) ≡ 417 (mod 439)
x ≡ 725 × 49-1 (mod 638) ≡ 725 × 625 (mod 638) ≡ 145 (mod 638)
x ≡ 614 × 303-1 (mod 217) ≡ 614 × 53 (mod 217) ≡ 209 (mod 217)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 439 × 638 × 217 = 60777794
  2. We calculate the numbers M1 to M3
    M1=M/m1=60777794/439=138446,   M2=M/m2=60777794/638=95263,   M3=M/m3=60777794/217=280082
  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
    4391384460439010
    138446439315161101
    439161211701-2
    1611171441-23
    11744229-23-8
    44291153-811
    2915114-811-19
    15141111-1930
    141140-1930-439
    So our multiplicative inverse is 30 mod 439 ≡ 30
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    638952630638010
    95263638149201101
    63820133501-3
    201355261-316
    352619-316-19
    2692816-1954
    9811-1954-73
    818054-73638
    So our multiplicative inverse is -73 mod 638 ≡ 565
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2172800820217010
    2800822171290152101
    21715216501-1
    152652221-13
    6522221-13-7
    2221113-710
    211210-710-217
    So our multiplicative inverse is 10 mod 217 ≡ 10
    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
    =  (417 × 138446 × 30 +
       145 × 95263 × 565 +
       209 × 280082 × 10)   mod 60777794
    = 32638311 (mod 60777794)


    So our answer is 32638311 (mod 60777794).


Verification

So we found that x ≡ 32638311
If this is correct, then the following statements (i.e. the original equations) are true:
323x (mod 439) ≡ 357 (mod 439)
49x (mod 638) ≡ 725 (mod 638)
303x (mod 217) ≡ 614 (mod 217)

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