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
1176814901-1
68491191-12
4919211-12-5
1911182-57
11813-57-12
83227-1231
3211-1231-43
212031-43117
So our multiplicative inverse is -43 mod 117 ≡ 74
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2517770251010
777251324101
25124101101-10
2411221-1021
11251-1021-115
212021-115251
So our multiplicative inverse is -115 mod 251 ≡ 136
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
85676519101-1
765918371-19
9137217-19-19
3717239-1947
17352-1947-254
321147-254301
2120-254301-856
So our multiplicative inverse is 301 mod 856 ≡ 301
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 ≡ 264 × 68-1 (mod 117) ≡ 264 × 74 (mod 117) ≡ 114 (mod 117)
x ≡ 428 × 777-1 (mod 251) ≡ 428 × 136 (mod 251) ≡ 227 (mod 251)
x ≡ 536 × 765-1 (mod 856) ≡ 536 × 301 (mod 856) ≡ 408 (mod 856)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 117 × 251 × 856 = 25138152
  2. We calculate the numbers M1 to M3
    M1=M/m1=25138152/117=214856,   M2=M/m2=25138152/251=100152,   M3=M/m3=25138152/856=29367
  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
    1172148560117010
    214856117183644101
    1174422901-2
    44291151-23
    2915114-23-5
    1514113-58
    141140-58-117
    So our multiplicative inverse is 8 mod 117 ≡ 8
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2511001520251010
    1001522513993101
    251383201-83
    32111-8384
    2120-8384-251
    So our multiplicative inverse is 84 mod 251 ≡ 84
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    856293670856010
    2936785634263101
    85626336701-3
    263673621-310
    676215-310-13
    62512210-13166
    5221-13166-345
    2120166-345856
    So our multiplicative inverse is -345 mod 856 ≡ 511
    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 × 214856 × 8 +
       227 × 100152 × 84 +
       408 × 29367 × 511)   mod 25138152
    = 8138400 (mod 25138152)


    So our answer is 8138400 (mod 25138152).


Verification

So we found that x ≡ 8138400
If this is correct, then the following statements (i.e. the original equations) are true:
68x (mod 117) ≡ 264 (mod 117)
777x (mod 251) ≡ 428 (mod 251)
765x (mod 856) ≡ 536 (mod 856)

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