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
853437141601-1
4374161211-12
416211917-12-39
2117142-3941
17441-3941-203
414041-203853
So our multiplicative inverse is -203 mod 853 ≡ 650
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
397269112801-1
2691282131-13
12813911-13-28
1311123-2831
11251-2831-183
212031-183397
So our multiplicative inverse is -183 mod 397 ≡ 214
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5998800599010
8805991281101
59928123701-2
281377221-215
3722115-215-17
22151715-1732
15721-1732-81
717032-81599
So our multiplicative inverse is -81 mod 599 ≡ 518
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 ≡ 550 × 437-1 (mod 853) ≡ 550 × 650 (mod 853) ≡ 93 (mod 853)
x ≡ 840 × 269-1 (mod 397) ≡ 840 × 214 (mod 397) ≡ 316 (mod 397)
x ≡ 198 × 880-1 (mod 599) ≡ 198 × 518 (mod 599) ≡ 135 (mod 599)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 853 × 397 × 599 = 202845959
  2. We calculate the numbers M1 to M3
    M1=M/m1=202845959/853=237803,   M2=M/m2=202845959/397=510947,   M3=M/m3=202845959/599=338641
  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
    8532378030853010
    237803853278669101
    853669118401-1
    66918431171-14
    184117167-14-5
    117671504-59
    6750117-59-14
    50172169-1437
    171611-1437-51
    16116037-51853
    So our multiplicative inverse is -51 mod 853 ≡ 802
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3975109470397010
    51094739712878101
    397849501-49
    85131-4950
    5312-4950-99
    321150-99149
    2120-99149-397
    So our multiplicative inverse is 149 mod 397 ≡ 149
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5993386410599010
    338641599565206101
    599206218701-2
    2061871191-23
    18719916-23-29
    1916133-2932
    16351-2932-189
    313032-189599
    So our multiplicative inverse is -189 mod 599 ≡ 410
    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
    =  (93 × 237803 × 802 +
       316 × 510947 × 149 +
       135 × 338641 × 410)   mod 202845959
    = 89886674 (mod 202845959)


    So our answer is 89886674 (mod 202845959).


Verification

So we found that x ≡ 89886674
If this is correct, then the following statements (i.e. the original equations) are true:
437x (mod 853) ≡ 550 (mod 853)
269x (mod 397) ≡ 840 (mod 397)
880x (mod 599) ≡ 198 (mod 599)

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