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
6078210607010
8216071214101
607214217901-2
2141791351-23
1793554-23-17
354833-17139
4311-17139-156
3130139-156607
So our multiplicative inverse is -156 mod 607 ≡ 451
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5099920509010
9925091483101
50948312601-1
4832618151-119
2615111-119-20
15111419-2039
11423-2039-98
431139-98137
3130-98137-509
So our multiplicative inverse is 137 mod 509 ≡ 137
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
77923332001-33
2320131-3334
20362-3334-237
321134-237271
2120-237271-779
So our multiplicative inverse is 271 mod 779 ≡ 271
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 ≡ 966 × 821-1 (mod 607) ≡ 966 × 451 (mod 607) ≡ 447 (mod 607)
x ≡ 805 × 992-1 (mod 509) ≡ 805 × 137 (mod 509) ≡ 341 (mod 509)
x ≡ 898 × 23-1 (mod 779) ≡ 898 × 271 (mod 779) ≡ 310 (mod 779)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 607 × 509 × 779 = 240682177
  2. We calculate the numbers M1 to M3
    M1=M/m1=240682177/607=396511,   M2=M/m2=240682177/509=472853,   M3=M/m3=240682177/779=308963
  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
    6073965110607010
    396511607653140101
    60714044701-4
    140472461-49
    474611-49-13
    4614609-13607
    So our multiplicative inverse is -13 mod 607 ≡ 594
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5094728530509010
    472853509928501101
    5095011801-1
    50186251-163
    8513-163-64
    531263-64127
    3211-64127-191
    2120127-191509
    So our multiplicative inverse is -191 mod 509 ≡ 318
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7793089630779010
    308963779396479101
    779479130001-1
    47930011791-12
    3001791121-12-3
    1791211582-35
    1215825-35-13
    5851135-13148
    5312-13148-161
    3211148-161309
    2120-161309-779
    So our multiplicative inverse is 309 mod 779 ≡ 309
    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
    =  (447 × 396511 × 594 +
       341 × 472853 × 318 +
       310 × 308963 × 309)   mod 240682177
    = 104284261 (mod 240682177)


    So our answer is 104284261 (mod 240682177).


Verification

So we found that x ≡ 104284261
If this is correct, then the following statements (i.e. the original equations) are true:
821x (mod 607) ≡ 966 (mod 607)
992x (mod 509) ≡ 805 (mod 509)
23x (mod 779) ≡ 898 (mod 779)

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