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
277151112601-1
1511261251-12
1262551-12-11
2512502-11277
So our multiplicative inverse is -11 mod 277 ≡ 266
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6559220655010
9226551267101
655267212101-2
2671212251-25
12125421-25-22
2521145-2227
21451-2227-157
414027-157655
So our multiplicative inverse is -157 mod 655 ≡ 498
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
68305068010
30568433101
68332201-2
3321611-233
2120-233-68
So our multiplicative inverse is 33 mod 68 ≡ 33
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 ≡ 163 × 151-1 (mod 277) ≡ 163 × 266 (mod 277) ≡ 146 (mod 277)
x ≡ 18 × 922-1 (mod 655) ≡ 18 × 498 (mod 655) ≡ 449 (mod 655)
x ≡ 947 × 305-1 (mod 68) ≡ 947 × 33 (mod 68) ≡ 39 (mod 68)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 277 × 655 × 68 = 12337580
  2. We calculate the numbers M1 to M3
    M1=M/m1=12337580/277=44540,   M2=M/m2=12337580/655=18836,   M3=M/m3=12337580/68=181435
  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
    277445400277010
    44540277160220101
    27722015701-1
    220573491-14
    574918-14-5
    498614-534
    8180-534-277
    So our multiplicative inverse is 34 mod 277 ≡ 34
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    655188360655010
    1883665528496101
    655496115901-1
    4961593191-14
    1591987-14-33
    197254-3370
    7512-3370-103
    522170-103276
    2120-103276-655
    So our multiplicative inverse is 276 mod 655 ≡ 276
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    68181435068010
    18143568266811101
    68116201-6
    112511-631
    2120-631-68
    So our multiplicative inverse is 31 mod 68 ≡ 31
    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
    =  (146 × 44540 × 34 +
       449 × 18836 × 276 +
       39 × 181435 × 31)   mod 12337580
    = 11066019 (mod 12337580)


    So our answer is 11066019 (mod 12337580).


Verification

So we found that x ≡ 11066019
If this is correct, then the following statements (i.e. the original equations) are true:
151x (mod 277) ≡ 163 (mod 277)
922x (mod 655) ≡ 18 (mod 655)
305x (mod 68) ≡ 947 (mod 68)

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