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
148295301-5
293921-546
3211-546-51
212046-51148
So our multiplicative inverse is -51 mod 148 ≡ 97
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
877534134301-1
53434311911-12
3431911152-12-3
1911521392-35
15239335-35-18
3935145-1823
35483-1823-202
431123-202225
3130-202225-877
So our multiplicative inverse is 225 mod 877 ≡ 225
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
949628132101-1
62832113071-12
321307114-12-3
3071421132-365
141311-365-68
13113065-68949
So our multiplicative inverse is -68 mod 949 ≡ 881
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 ≡ 639 × 29-1 (mod 148) ≡ 639 × 97 (mod 148) ≡ 119 (mod 148)
x ≡ 400 × 534-1 (mod 877) ≡ 400 × 225 (mod 877) ≡ 546 (mod 877)
x ≡ 559 × 628-1 (mod 949) ≡ 559 × 881 (mod 949) ≡ 897 (mod 949)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 148 × 877 × 949 = 123176404
  2. We calculate the numbers M1 to M3
    M1=M/m1=123176404/148=832273,   M2=M/m2=123176404/877=140452,   M3=M/m3=123176404/949=129796
  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
    1488322730148010
    832273148562369101
    1486921001-2
    6910691-213
    10911-213-15
    919013-15148
    So our multiplicative inverse is -15 mod 148 ≡ 133
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8771404520877010
    140452877160132101
    87713268501-6
    132851471-67
    8547138-67-13
    4738197-1320
    38942-1320-93
    924120-93392
    2120-93392-877
    So our multiplicative inverse is 392 mod 877 ≡ 392
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9491297960949010
    129796949136732101
    949732121701-1
    7322173811-14
    21781255-14-9
    81551264-913
    552623-913-35
    2638213-35293
    3211-35293-328
    2120293-328949
    So our multiplicative inverse is -328 mod 949 ≡ 621
    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
    =  (119 × 832273 × 133 +
       546 × 140452 × 392 +
       897 × 129796 × 621)   mod 123176404
    = 118491139 (mod 123176404)


    So our answer is 118491139 (mod 123176404).


Verification

So we found that x ≡ 118491139
If this is correct, then the following statements (i.e. the original equations) are true:
29x (mod 148) ≡ 639 (mod 148)
534x (mod 877) ≡ 400 (mod 877)
628x (mod 949) ≡ 559 (mod 949)

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