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
8419180841010
918841177101
84177107101-10
7771161-1011
716115-1011-131
651111-131142
5150-131142-841
So our multiplicative inverse is 142 mod 841 ≡ 142
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1393790139010
3791392101101
13910113801-1
101382251-13
3825113-13-4
25131123-47
131211-47-11
1211207-11139
So our multiplicative inverse is -11 mod 139 ≡ 128
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3595520359010
5523591193101
359193116601-1
1931661271-12
1662764-12-13
274632-1380
4311-1380-93
313080-93359
So our multiplicative inverse is -93 mod 359 ≡ 266
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 ≡ 850 × 918-1 (mod 841) ≡ 850 × 142 (mod 841) ≡ 437 (mod 841)
x ≡ 49 × 379-1 (mod 139) ≡ 49 × 128 (mod 139) ≡ 17 (mod 139)
x ≡ 375 × 552-1 (mod 359) ≡ 375 × 266 (mod 359) ≡ 307 (mod 359)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 841 × 139 × 359 = 41966741
  2. We calculate the numbers M1 to M3
    M1=M/m1=41966741/841=49901,   M2=M/m2=41966741/139=301919,   M3=M/m3=41966741/359=116899
  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
    841499010841010
    4990184159282101
    841282227701-2
    282277151-23
    2775552-23-167
    52213-167337
    2120-167337-841
    So our multiplicative inverse is 337 mod 841 ≡ 337
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1393019190139010
    301919139217211101
    1391112701-12
    117141-1213
    7413-1213-25
    431113-2538
    3130-2538-139
    So our multiplicative inverse is 38 mod 139 ≡ 38
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3591168990359010
    116899359325224101
    359224113501-1
    2241351891-12
    13589146-12-3
    89461432-35
    464313-35-8
    4331415-8117
    3130-8117-359
    So our multiplicative inverse is 117 mod 359 ≡ 117
    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
    =  (437 × 49901 × 337 +
       17 × 301919 × 38 +
       307 × 116899 × 117)   mod 41966741
    = 34084485 (mod 41966741)


    So our answer is 34084485 (mod 41966741).


Verification

So we found that x ≡ 34084485
If this is correct, then the following statements (i.e. the original equations) are true:
918x (mod 841) ≡ 850 (mod 841)
379x (mod 139) ≡ 49 (mod 139)
552x (mod 359) ≡ 375 (mod 359)

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