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
85720045701-4
200573291-413
5729128-413-17
29281113-1730
281280-1730-857
So our multiplicative inverse is 30 mod 857 ≡ 30
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1632480163010
248163185101
1638517801-1
8578171-12
787111-12-23
71702-23163
So our multiplicative inverse is -23 mod 163 ≡ 140
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4694790469010
479469110101
4691046901-46
109111-4647
9190-4647-469
So our multiplicative inverse is 47 mod 469 ≡ 47
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 ≡ 366 × 200-1 (mod 857) ≡ 366 × 30 (mod 857) ≡ 696 (mod 857)
x ≡ 725 × 248-1 (mod 163) ≡ 725 × 140 (mod 163) ≡ 114 (mod 163)
x ≡ 437 × 479-1 (mod 469) ≡ 437 × 47 (mod 469) ≡ 372 (mod 469)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 857 × 163 × 469 = 65515079
  2. We calculate the numbers M1 to M3
    M1=M/m1=65515079/857=76447,   M2=M/m2=65515079/163=401933,   M3=M/m3=65515079/469=139691
  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
    857764470857010
    7644785789174101
    857174416101-4
    1741611131-45
    16113125-45-64
    135235-64133
    5312-64133-197
    3211133-197330
    2120-197330-857
    So our multiplicative inverse is 330 mod 857 ≡ 330
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1634019330163010
    4019331632465138101
    16313812501-1
    138255131-16
    2513112-16-7
    1312116-713
    121120-713-163
    So our multiplicative inverse is 13 mod 163 ≡ 13
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4691396910469010
    139691469297398101
    46939817101-1
    398715431-16
    7143128-16-7
    43281156-713
    2815113-713-20
    15131213-2033
    13261-2033-218
    212033-218469
    So our multiplicative inverse is -218 mod 469 ≡ 251
    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
    =  (696 × 76447 × 330 +
       114 × 401933 × 13 +
       372 × 139691 × 251)   mod 65515079
    = 12062114 (mod 65515079)


    So our answer is 12062114 (mod 65515079).


Verification

So we found that x ≡ 12062114
If this is correct, then the following statements (i.e. the original equations) are true:
200x (mod 857) ≡ 366 (mod 857)
248x (mod 163) ≡ 725 (mod 163)
479x (mod 469) ≡ 437 (mod 469)

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