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
3776356201-5
6362111-56
621620-56-377
So our multiplicative inverse is 6 mod 377 ≡ 6
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
62620531101-3
205111871-355
11714-355-58
741355-58113
4311-58113-171
3130113-171626
So our multiplicative inverse is -171 mod 626 ≡ 455
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
889244315701-3
2441571871-34
15787170-34-7
87701174-711
701742-711-51
1728111-51419
2120-51419-889
So our multiplicative inverse is 419 mod 889 ≡ 419
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 ≡ 127 × 63-1 (mod 377) ≡ 127 × 6 (mod 377) ≡ 8 (mod 377)
x ≡ 94 × 205-1 (mod 626) ≡ 94 × 455 (mod 626) ≡ 202 (mod 626)
x ≡ 298 × 244-1 (mod 889) ≡ 298 × 419 (mod 889) ≡ 402 (mod 889)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 377 × 626 × 889 = 209805778
  2. We calculate the numbers M1 to M3
    M1=M/m1=209805778/377=556514,   M2=M/m2=209805778/626=335153,   M3=M/m3=209805778/889=236002
  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
    3775565140377010
    556514377147662101
    377626501-6
    6251221-673
    5221-673-152
    212073-152377
    So our multiplicative inverse is -152 mod 377 ≡ 225
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6263351530626010
    335153626535243101
    626243214001-2
    24314011031-23
    140103137-23-5
    103372293-513
    372918-513-18
    2983513-1867
    8513-1867-85
    531267-85152
    3211-85152-237
    2120152-237626
    So our multiplicative inverse is -237 mod 626 ≡ 389
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8892360020889010
    236002889265417101
    88941725501-2
    417557321-215
    5532123-215-17
    32231915-1732
    23925-1732-81
    951432-81113
    5411-81113-194
    4140113-194889
    So our multiplicative inverse is -194 mod 889 ≡ 695
    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
    =  (8 × 556514 × 225 +
       202 × 335153 × 389 +
       402 × 236002 × 695)   mod 209805778
    = 120210982 (mod 209805778)


    So our answer is 120210982 (mod 209805778).


Verification

So we found that x ≡ 120210982
If this is correct, then the following statements (i.e. the original equations) are true:
63x (mod 377) ≡ 127 (mod 377)
205x (mod 626) ≡ 94 (mod 626)
244x (mod 889) ≡ 298 (mod 889)

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