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
2777550277010
7552772201101
27720117601-1
201762491-13
7649127-13-4
49271223-47
272215-47-11
225427-1151
5221-1151-113
212051-113277
So our multiplicative inverse is -113 mod 277 ≡ 164
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1932460193010
246193153101
1935333401-3
53341191-34
3419115-34-7
1915144-711
15433-711-40
431111-4051
3130-4051-193
So our multiplicative inverse is 51 mod 193 ≡ 51
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
97786113101-11
86312241-1123
312417-1123-34
2473323-34125
7321-34125-284
3130125-284977
So our multiplicative inverse is -284 mod 977 ≡ 693
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 ≡ 816 × 755-1 (mod 277) ≡ 816 × 164 (mod 277) ≡ 33 (mod 277)
x ≡ 401 × 246-1 (mod 193) ≡ 401 × 51 (mod 193) ≡ 186 (mod 193)
x ≡ 417 × 86-1 (mod 977) ≡ 417 × 693 (mod 977) ≡ 766 (mod 977)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 277 × 193 × 977 = 52231397
  2. We calculate the numbers M1 to M3
    M1=M/m1=52231397/277=188561,   M2=M/m2=52231397/193=270629,   M3=M/m3=52231397/977=53461
  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
    2771885610277010
    188561277680201101
    27720117601-1
    201762491-13
    7649127-13-4
    49271223-47
    272215-47-11
    225427-1151
    5221-1151-113
    212051-113277
    So our multiplicative inverse is -113 mod 277 ≡ 164
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1932706290193010
    270629193140243101
    1934342101-4
    4321211-49
    211210-49-193
    So our multiplicative inverse is 9 mod 193 ≡ 9
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    977534610977010
    5346197754703101
    977703127401-1
    70327421551-13
    2741551119-13-4
    1551191363-47
    11936311-47-25
    3611337-2582
    11332-2582-271
    321182-271353
    2120-271353-977
    So our multiplicative inverse is 353 mod 977 ≡ 353
    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
    =  (33 × 188561 × 164 +
       186 × 270629 × 9 +
       766 × 53461 × 353)   mod 52231397
    = 50927868 (mod 52231397)


    So our answer is 50927868 (mod 52231397).


Verification

So we found that x ≡ 50927868
If this is correct, then the following statements (i.e. the original equations) are true:
755x (mod 277) ≡ 816 (mod 277)
246x (mod 193) ≡ 401 (mod 193)
86x (mod 977) ≡ 417 (mod 977)

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