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
1693340169010
3341691165101
1691651401-1
16544111-142
4140-142-169
So our multiplicative inverse is 42 mod 169 ≡ 42
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
78764121901-12
6419371-1237
19725-1237-86
751237-86123
5221-86123-332
2120123-332787
So our multiplicative inverse is -332 mod 787 ≡ 455
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
911240319101-3
2401911491-34
19149344-34-15
4944154-1519
44584-1519-167
541119-167186
4140-167186-911
So our multiplicative inverse is 186 mod 911 ≡ 186
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 ≡ 286 × 334-1 (mod 169) ≡ 286 × 42 (mod 169) ≡ 13 (mod 169)
x ≡ 127 × 64-1 (mod 787) ≡ 127 × 455 (mod 787) ≡ 334 (mod 787)
x ≡ 172 × 240-1 (mod 911) ≡ 172 × 186 (mod 911) ≡ 107 (mod 911)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 169 × 787 × 911 = 121165733
  2. We calculate the numbers M1 to M3
    M1=M/m1=121165733/169=716957,   M2=M/m2=121165733/787=153959,   M3=M/m3=121165733/911=133003
  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
    1697169570169010
    716957169424259101
    1695925101-2
    5951181-23
    51863-23-20
    83223-2043
    3211-2043-63
    212043-63169
    So our multiplicative inverse is -63 mod 169 ≡ 106
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7871539590787010
    153959787195494101
    787494129301-1
    49429312011-12
    293201192-12-3
    201922172-38
    921757-38-43
    177238-4394
    7321-4394-231
    313094-231787
    So our multiplicative inverse is -231 mod 787 ≡ 556
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9111330030911010
    133003911145908101
    9119081301-1
    908330221-1303
    3211-1303-304
    2120303-304911
    So our multiplicative inverse is -304 mod 911 ≡ 607
    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
    =  (13 × 716957 × 106 +
       334 × 153959 × 556 +
       107 × 133003 × 607)   mod 121165733
    = 49974834 (mod 121165733)


    So our answer is 49974834 (mod 121165733).


Verification

So we found that x ≡ 49974834
If this is correct, then the following statements (i.e. the original equations) are true:
334x (mod 169) ≡ 286 (mod 169)
64x (mod 787) ≡ 127 (mod 787)
240x (mod 911) ≡ 172 (mod 911)

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