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
59956513401-1
5653416211-117
3421113-117-18
21131817-1835
13815-1835-53
851335-5388
5312-5388-141
321188-141229
2120-141229-599
So our multiplicative inverse is 229 mod 599 ≡ 229
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4034740403010
474403171101
4037154801-5
71481231-56
482322-56-17
2321116-17193
2120-17193-403
So our multiplicative inverse is 193 mod 403 ≡ 193
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4399200439010
920439242101
43942101901-10
4219241-1021
19443-1021-94
431121-94115
3130-94115-439
So our multiplicative inverse is 115 mod 439 ≡ 115
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 ≡ 271 × 565-1 (mod 599) ≡ 271 × 229 (mod 599) ≡ 362 (mod 599)
x ≡ 745 × 474-1 (mod 403) ≡ 745 × 193 (mod 403) ≡ 317 (mod 403)
x ≡ 261 × 920-1 (mod 439) ≡ 261 × 115 (mod 439) ≡ 163 (mod 439)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 599 × 403 × 439 = 105973283
  2. We calculate the numbers M1 to M3
    M1=M/m1=105973283/599=176917,   M2=M/m2=105973283/403=262961,   M3=M/m3=105973283/439=241397
  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
    5991769170599010
    176917599295212101
    599212217501-2
    2121751371-23
    17537427-23-14
    37271103-1417
    271027-1417-48
    1071317-4865
    7321-4865-178
    313065-178599
    So our multiplicative inverse is -178 mod 599 ≡ 421
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4032629610403010
    262961403652205101
    403205119801-1
    205198171-12
    1987282-12-57
    72312-57173
    2120-57173-403
    So our multiplicative inverse is 173 mod 403 ≡ 173
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4392413970439010
    241397439549386101
    43938615301-1
    386537151-18
    531538-18-25
    158178-2533
    8711-2533-58
    717033-58439
    So our multiplicative inverse is -58 mod 439 ≡ 381
    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
    =  (362 × 176917 × 421 +
       317 × 262961 × 173 +
       163 × 241397 × 381)   mod 105973283
    = 103213453 (mod 105973283)


    So our answer is 103213453 (mod 105973283).


Verification

So we found that x ≡ 103213453
If this is correct, then the following statements (i.e. the original equations) are true:
565x (mod 599) ≡ 271 (mod 599)
474x (mod 403) ≡ 745 (mod 403)
920x (mod 439) ≡ 261 (mod 439)

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