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
50941419501-1
414954341-15
9534227-15-11
3427175-1116
27736-1116-59
761116-5975
6160-5975-509
So our multiplicative inverse is 75 mod 509 ≡ 75
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
866489137701-1
48937711121-12
377112341-12-7
112412302-716
4130111-716-23
30112816-2362
11813-2362-85
832262-85232
3211-85232-317
2120232-317866
So our multiplicative inverse is -317 mod 866 ≡ 549
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6737450673010
745673172101
6737292501-9
72252221-919
252213-919-28
2237119-28215
3130-28215-673
So our multiplicative inverse is 215 mod 673 ≡ 215
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 ≡ 553 × 414-1 (mod 509) ≡ 553 × 75 (mod 509) ≡ 246 (mod 509)
x ≡ 104 × 489-1 (mod 866) ≡ 104 × 549 (mod 866) ≡ 806 (mod 866)
x ≡ 990 × 745-1 (mod 673) ≡ 990 × 215 (mod 673) ≡ 182 (mod 673)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 509 × 866 × 673 = 296654362
  2. We calculate the numbers M1 to M3
    M1=M/m1=296654362/509=582818,   M2=M/m2=296654362/866=342557,   M3=M/m3=296654362/673=440794
  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
    5095828180509010
    582818509114513101
    5091339201-39
    132611-39235
    2120-39235-509
    So our multiplicative inverse is 235 mod 509 ≡ 235
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8663425570866010
    342557866395487101
    866487137901-1
    48737911081-12
    379108355-12-7
    108551532-79
    555312-79-16
    5322619-16425
    2120-16425-866
    So our multiplicative inverse is 425 mod 866 ≡ 425
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6734407940673010
    440794673654652101
    67365212101-1
    652213111-132
    211210-132-673
    So our multiplicative inverse is 32 mod 673 ≡ 32
    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
    =  (246 × 582818 × 235 +
       806 × 342557 × 425 +
       182 × 440794 × 32)   mod 296654362
    = 232488032 (mod 296654362)


    So our answer is 232488032 (mod 296654362).


Verification

So we found that x ≡ 232488032
If this is correct, then the following statements (i.e. the original equations) are true:
414x (mod 509) ≡ 553 (mod 509)
489x (mod 866) ≡ 104 (mod 866)
745x (mod 673) ≡ 990 (mod 673)

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