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
1731671601-1
16762751-128
6511-128-29
515028-29173
So our multiplicative inverse is -29 mod 173 ≡ 144
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2016231501-3
6215421-313
15271-313-94
212013-94201
So our multiplicative inverse is -94 mod 201 ≡ 107
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3895420389010
5423891153101
38915328301-2
153831701-23
8370113-23-5
7013553-528
13523-528-61
531228-6189
3211-6189-150
212089-150389
So our multiplicative inverse is -150 mod 389 ≡ 239
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 ≡ 8 × 167-1 (mod 173) ≡ 8 × 144 (mod 173) ≡ 114 (mod 173)
x ≡ 213 × 62-1 (mod 201) ≡ 213 × 107 (mod 201) ≡ 78 (mod 201)
x ≡ 72 × 542-1 (mod 389) ≡ 72 × 239 (mod 389) ≡ 92 (mod 389)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 173 × 201 × 389 = 13526697
  2. We calculate the numbers M1 to M3
    M1=M/m1=13526697/173=78189,   M2=M/m2=13526697/201=67297,   M3=M/m3=13526697/389=34773
  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
    173781890173010
    78189173451166101
    1731661701-1
    16672351-124
    7512-124-25
    522124-2574
    2120-2574-173
    So our multiplicative inverse is 74 mod 173 ≡ 74
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    201672970201010
    67297201334163101
    20116313801-1
    163384111-15
    381135-15-16
    115215-1637
    5150-1637-201
    So our multiplicative inverse is 37 mod 201 ≡ 37
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    389347730389010
    3477338989152101
    38915228501-2
    152851671-23
    8567118-23-5
    67183133-518
    181315-518-23
    1352318-2364
    5312-2364-87
    321164-87151
    2120-87151-389
    So our multiplicative inverse is 151 mod 389 ≡ 151
    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
    =  (114 × 78189 × 74 +
       78 × 67297 × 37 +
       92 × 34773 × 151)   mod 13526697
    = 11271756 (mod 13526697)


    So our answer is 11271756 (mod 13526697).


Verification

So we found that x ≡ 11271756
If this is correct, then the following statements (i.e. the original equations) are true:
167x (mod 173) ≡ 8 (mod 173)
62x (mod 201) ≡ 213 (mod 201)
542x (mod 389) ≡ 72 (mod 389)

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