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
2154040215010
4042151189101
21518912601-1
18926771-18
26735-18-25
75128-2533
5221-2533-91
212033-91215
So our multiplicative inverse is -91 mod 215 ≡ 124
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
923535138801-1
53538811471-12
388147294-12-5
147941532-57
9453141-57-12
53411127-1219
411235-1219-69
1252219-69157
5221-69157-383
2120157-383923
So our multiplicative inverse is -383 mod 923 ≡ 540
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3279880327010
98832737101
327746501-46
75121-4647
5221-4647-140
212047-140327
So our multiplicative inverse is -140 mod 327 ≡ 187
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 ≡ 821 × 404-1 (mod 215) ≡ 821 × 124 (mod 215) ≡ 109 (mod 215)
x ≡ 722 × 535-1 (mod 923) ≡ 722 × 540 (mod 923) ≡ 374 (mod 923)
x ≡ 622 × 988-1 (mod 327) ≡ 622 × 187 (mod 327) ≡ 229 (mod 327)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 215 × 923 × 327 = 64891515
  2. We calculate the numbers M1 to M3
    M1=M/m1=64891515/215=301821,   M2=M/m2=64891515/923=70305,   M3=M/m3=64891515/327=198445
  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
    2153018210215010
    3018212151403176101
    21517613901-1
    176394201-15
    3920119-15-6
    2019115-611
    191190-611-215
    So our multiplicative inverse is 11 mod 215 ≡ 11
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    923703050923010
    7030592376157101
    923157513801-5
    1571381191-56
    1381975-56-47
    195346-47147
    5411-47147-194
    4140147-194923
    So our multiplicative inverse is -194 mod 923 ≡ 729
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3271984450327010
    198445327606283101
    32728314401-1
    283446191-17
    441926-17-15
    196317-1552
    6160-1552-327
    So our multiplicative inverse is 52 mod 327 ≡ 52
    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
    =  (109 × 301821 × 11 +
       374 × 70305 × 729 +
       229 × 198445 × 52)   mod 64891515
    = 24902914 (mod 64891515)


    So our answer is 24902914 (mod 64891515).


Verification

So we found that x ≡ 24902914
If this is correct, then the following statements (i.e. the original equations) are true:
404x (mod 215) ≡ 821 (mod 215)
535x (mod 923) ≡ 722 (mod 923)
988x (mod 327) ≡ 622 (mod 327)

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