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
4875950487010
5954871108101
48710845501-4
108551531-45
555312-45-9
5322615-9239
2120-9239-487
So our multiplicative inverse is 239 mod 487 ≡ 239
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7695115401-15
5141231-15181
4311-15181-196
3130181-196769
So our multiplicative inverse is -196 mod 769 ≡ 573
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
931165510601-5
1651061591-56
10659147-56-11
59471126-1117
4712311-1117-62
12111117-6279
111110-6279-931
So our multiplicative inverse is 79 mod 931 ≡ 79
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 ≡ 201 × 595-1 (mod 487) ≡ 201 × 239 (mod 487) ≡ 313 (mod 487)
x ≡ 948 × 51-1 (mod 769) ≡ 948 × 573 (mod 769) ≡ 290 (mod 769)
x ≡ 429 × 165-1 (mod 931) ≡ 429 × 79 (mod 931) ≡ 375 (mod 931)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 487 × 769 × 931 = 348662293
  2. We calculate the numbers M1 to M3
    M1=M/m1=348662293/487=715939,   M2=M/m2=348662293/769=453397,   M3=M/m3=348662293/931=374503
  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
    4877159390487010
    715939487147049101
    4874994601-9
    4946131-910
    463151-910-159
    313010-159487
    So our multiplicative inverse is -159 mod 487 ≡ 328
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7694533970769010
    453397769589456101
    769456131301-1
    45631311431-12
    313143227-12-5
    14327582-527
    27833-527-86
    832227-86199
    3211-86199-285
    2120199-285769
    So our multiplicative inverse is -285 mod 769 ≡ 484
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9313745030931010
    374503931402241101
    931241320801-3
    2412081331-34
    20833610-34-27
    3310334-2785
    10331-2785-282
    313085-282931
    So our multiplicative inverse is -282 mod 931 ≡ 649
    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
    =  (313 × 715939 × 328 +
       290 × 453397 × 484 +
       375 × 374503 × 649)   mod 348662293
    = 259492419 (mod 348662293)


    So our answer is 259492419 (mod 348662293).


Verification

So we found that x ≡ 259492419
If this is correct, then the following statements (i.e. the original equations) are true:
595x (mod 487) ≡ 201 (mod 487)
51x (mod 769) ≡ 948 (mod 769)
165x (mod 931) ≡ 429 (mod 931)

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