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
13851013010
85113656101
1362101-2
61601-213
So our multiplicative inverse is -2 mod 13 ≡ 11
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4214290421010
42942118101
421852501-52
85131-5253
5312-5253-105
321153-105158
2120-105158-421
So our multiplicative inverse is 158 mod 421 ≡ 158
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
857657120001-1
6572003571-14
20057329-14-13
57291284-1317
292811-1317-30
28128017-30857
So our multiplicative inverse is -30 mod 857 ≡ 827
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 ≡ 370 × 851-1 (mod 13) ≡ 370 × 11 (mod 13) ≡ 1 (mod 13)
x ≡ 398 × 429-1 (mod 421) ≡ 398 × 158 (mod 421) ≡ 155 (mod 421)
x ≡ 483 × 657-1 (mod 857) ≡ 483 × 827 (mod 857) ≡ 79 (mod 857)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 13 × 421 × 857 = 4690361
  2. We calculate the numbers M1 to M3
    M1=M/m1=4690361/13=360797,   M2=M/m2=4690361/421=11141,   M3=M/m3=4690361/857=5473
  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
    13360797013010
    36079713277538101
    1381501-1
    85131-12
    5312-12-3
    32112-35
    2120-35-13
    So our multiplicative inverse is 5 mod 13 ≡ 5
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    421111410421010
    1114142126195101
    42119523101-2
    19531691-213
    31934-213-41
    942113-4195
    4140-4195-421
    So our multiplicative inverse is 95 mod 421 ≡ 95
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    85754730857010
    54738576331101
    857331219501-2
    33119511361-23
    195136159-23-5
    136592183-513
    591835-513-44
    1853313-44145
    5312-44145-189
    3211145-189334
    2120-189334-857
    So our multiplicative inverse is 334 mod 857 ≡ 334
    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
    =  (1 × 360797 × 5 +
       155 × 11141 × 95 +
       79 × 5473 × 334)   mod 4690361
    = 701962 (mod 4690361)


    So our answer is 701962 (mod 4690361).


Verification

So we found that x ≡ 701962
If this is correct, then the following statements (i.e. the original equations) are true:
851x (mod 13) ≡ 370 (mod 13)
429x (mod 421) ≡ 398 (mod 421)
657x (mod 857) ≡ 483 (mod 857)

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