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
4678350467010
8354671368101
46736819901-1
368993711-14
9971128-14-5
71282154-514
2815113-514-19
15131214-1933
13261-1933-217
212033-217467
So our multiplicative inverse is -217 mod 467 ≡ 250
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1237690123010
769123631101
1233133001-3
3130111-34
301300-34-123
So our multiplicative inverse is 4 mod 123 ≡ 4
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5035610503010
561503158101
5035883901-8
58391191-89
391921-89-26
1911909-26503
So our multiplicative inverse is -26 mod 503 ≡ 477
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 ≡ 374 × 835-1 (mod 467) ≡ 374 × 250 (mod 467) ≡ 100 (mod 467)
x ≡ 681 × 769-1 (mod 123) ≡ 681 × 4 (mod 123) ≡ 18 (mod 123)
x ≡ 862 × 561-1 (mod 503) ≡ 862 × 477 (mod 503) ≡ 223 (mod 503)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 467 × 123 × 503 = 28892823
  2. We calculate the numbers M1 to M3
    M1=M/m1=28892823/467=61869,   M2=M/m2=28892823/123=234901,   M3=M/m3=28892823/503=57441
  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
    467618690467010
    61869467132225101
    46722521701-2
    225171341-227
    17441-227-110
    414027-110467
    So our multiplicative inverse is -110 mod 467 ≡ 357
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1232349010123010
    234901123190994101
    1239412901-1
    9429371-14
    29741-14-17
    71704-17123
    So our multiplicative inverse is -17 mod 123 ≡ 106
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    503574410503010
    5744150311499101
    503995801-5
    9981231-561
    8322-561-127
    321161-127188
    2120-127188-503
    So our multiplicative inverse is 188 mod 503 ≡ 188
    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
    =  (100 × 61869 × 357 +
       18 × 234901 × 106 +
       223 × 57441 × 188)   mod 28892823
    = 8826867 (mod 28892823)


    So our answer is 8826867 (mod 28892823).


Verification

So we found that x ≡ 8826867
If this is correct, then the following statements (i.e. the original equations) are true:
835x (mod 467) ≡ 374 (mod 467)
769x (mod 123) ≡ 681 (mod 123)
561x (mod 503) ≡ 862 (mod 503)

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