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
3496940349010
6943491345101
3493451401-1
34548611-187
4140-187-349
So our multiplicative inverse is 87 mod 349 ≡ 87
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3768942001-4
8920491-417
20922-417-38
924117-38169
2120-38169-376
So our multiplicative inverse is 169 mod 376 ≡ 169
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
667259214901-2
25914911101-23
149110139-23-5
110392323-513
393217-513-18
3274413-1885
7413-1885-103
431185-103188
3130-103188-667
So our multiplicative inverse is 188 mod 667 ≡ 188
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 ≡ 914 × 694-1 (mod 349) ≡ 914 × 87 (mod 349) ≡ 295 (mod 349)
x ≡ 279 × 89-1 (mod 376) ≡ 279 × 169 (mod 376) ≡ 151 (mod 376)
x ≡ 157 × 259-1 (mod 667) ≡ 157 × 188 (mod 667) ≡ 168 (mod 667)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 349 × 376 × 667 = 87526408
  2. We calculate the numbers M1 to M3
    M1=M/m1=87526408/349=250792,   M2=M/m2=87526408/376=232783,   M3=M/m3=87526408/667=131224
  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
    3492507920349010
    250792349718210101
    349210113901-1
    2101391711-12
    13971168-12-3
    7168132-35
    683222-35-113
    32115-113118
    2120-113118-349
    So our multiplicative inverse is 118 mod 349 ≡ 118
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3762327830376010
    23278337661939101
    3763992501-9
    39251141-910
    2514111-910-19
    14111310-1929
    11332-1929-106
    321129-106135
    2120-106135-376
    So our multiplicative inverse is 135 mod 376 ≡ 135
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6671312240667010
    131224667196492101
    667492117501-1
    49217521421-13
    175142133-13-4
    142334103-419
    331033-419-61
    1033119-61202
    3130-61202-667
    So our multiplicative inverse is 202 mod 667 ≡ 202
    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
    =  (295 × 250792 × 118 +
       151 × 232783 × 135 +
       168 × 131224 × 202)   mod 87526408
    = 73181407 (mod 87526408)


    So our answer is 73181407 (mod 87526408).


Verification

So we found that x ≡ 73181407
If this is correct, then the following statements (i.e. the original equations) are true:
694x (mod 349) ≡ 914 (mod 349)
89x (mod 376) ≡ 279 (mod 376)
259x (mod 667) ≡ 157 (mod 667)

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