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
94787117601-1
8717611351-112
763526-112-25
3565512-25137
6511-25137-162
5150137-162947
So our multiplicative inverse is -162 mod 947 ≡ 785
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
9019100101-100
91901-100901
So our multiplicative inverse is -100 mod 901 ≡ 801
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3525550352010
5553521203101
352203114901-1
2031491541-12
14954241-12-5
54411132-57
411332-57-26
132617-26163
2120-26163-352
So our multiplicative inverse is 163 mod 352 ≡ 163
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 ≡ 528 × 871-1 (mod 947) ≡ 528 × 785 (mod 947) ≡ 641 (mod 947)
x ≡ 106 × 9-1 (mod 901) ≡ 106 × 801 (mod 901) ≡ 212 (mod 901)
x ≡ 123 × 555-1 (mod 352) ≡ 123 × 163 (mod 352) ≡ 337 (mod 352)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 947 × 901 × 352 = 300342944
  2. We calculate the numbers M1 to M3
    M1=M/m1=300342944/947=317152,   M2=M/m2=300342944/901=333344,   M3=M/m3=300342944/352=853247
  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
    9473171520947010
    317152947334854101
    94785419301-1
    854939171-110
    931758-110-51
    1782110-51112
    8180-51112-947
    So our multiplicative inverse is 112 mod 947 ≡ 112
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9013333440901010
    333344901369875101
    90187512601-1
    8752633171-134
    261719-134-35
    1791834-3569
    9811-3569-104
    818069-104901
    So our multiplicative inverse is -104 mod 901 ≡ 797
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3528532470352010
    8532473522423351101
    3523511101-1
    351135101-1352
    So our multiplicative inverse is -1 mod 352 ≡ 351
    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
    =  (641 × 317152 × 112 +
       212 × 333344 × 797 +
       337 × 853247 × 351)   mod 300342944
    = 114716433 (mod 300342944)


    So our answer is 114716433 (mod 300342944).


Verification

So we found that x ≡ 114716433
If this is correct, then the following statements (i.e. the original equations) are true:
871x (mod 947) ≡ 528 (mod 947)
9x (mod 901) ≡ 106 (mod 901)
555x (mod 352) ≡ 123 (mod 352)

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