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
2394280239010
4282391189101
23918915001-1
189503391-14
5039111-14-5
3911364-519
11615-519-24
651119-2443
5150-2443-239
So our multiplicative inverse is 43 mod 239 ≡ 43
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
643264211501-2
2641152341-25
11534313-25-17
3413285-1739
13815-1739-56
851339-5695
5312-5695-151
321195-151246
2120-151246-643
So our multiplicative inverse is 246 mod 643 ≡ 246
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
881192411301-4
1921131791-45
11379134-45-9
79342115-923
341131-923-78
11111023-78881
So our multiplicative inverse is -78 mod 881 ≡ 803
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 ≡ 906 × 428-1 (mod 239) ≡ 906 × 43 (mod 239) ≡ 1 (mod 239)
x ≡ 108 × 264-1 (mod 643) ≡ 108 × 246 (mod 643) ≡ 205 (mod 643)
x ≡ 534 × 192-1 (mod 881) ≡ 534 × 803 (mod 881) ≡ 636 (mod 881)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 239 × 643 × 881 = 135389437
  2. We calculate the numbers M1 to M3
    M1=M/m1=135389437/239=566483,   M2=M/m2=135389437/643=210559,   M3=M/m3=135389437/881=153677
  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
    2395664830239010
    566483239237053101
    2395342701-4
    53271261-45
    272611-45-9
    2612605-9239
    So our multiplicative inverse is -9 mod 239 ≡ 230
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6432105590643010
    210559643327298101
    64329824701-2
    298476161-213
    4716215-213-28
    16151113-2841
    151150-2841-643
    So our multiplicative inverse is 41 mod 643 ≡ 41
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8811536770881010
    153677881174383101
    881383211501-2
    3831153381-27
    1153831-27-23
    3813807-23881
    So our multiplicative inverse is -23 mod 881 ≡ 858
    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
    =  (1 × 566483 × 230 +
       205 × 210559 × 41 +
       636 × 153677 × 858)   mod 135389437
    = 58220640 (mod 135389437)


    So our answer is 58220640 (mod 135389437).


Verification

So we found that x ≡ 58220640
If this is correct, then the following statements (i.e. the original equations) are true:
428x (mod 239) ≡ 906 (mod 239)
264x (mod 643) ≡ 108 (mod 643)
192x (mod 881) ≡ 534 (mod 881)

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