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
1575490157010
549157378101
157782101-2
7817801-2157
So our multiplicative inverse is -2 mod 157 ≡ 155
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
75123321501-32
2315181-3233
15817-3233-65
871133-6598
7170-6598-751
So our multiplicative inverse is 98 mod 751 ≡ 98
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
956501145501-1
5014551461-12
45546941-12-19
4641152-1921
41581-1921-187
515021-187956
So our multiplicative inverse is -187 mod 956 ≡ 769
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 ≡ 237 × 549-1 (mod 157) ≡ 237 × 155 (mod 157) ≡ 154 (mod 157)
x ≡ 598 × 23-1 (mod 751) ≡ 598 × 98 (mod 751) ≡ 26 (mod 751)
x ≡ 153 × 501-1 (mod 956) ≡ 153 × 769 (mod 956) ≡ 69 (mod 956)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 157 × 751 × 956 = 112719092
  2. We calculate the numbers M1 to M3
    M1=M/m1=112719092/157=717956,   M2=M/m2=112719092/751=150092,   M3=M/m3=112719092/956=117907
  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
    1577179560157010
    7179561574572152101
    1571521501-1
    15253021-131
    5221-131-63
    212031-63157
    So our multiplicative inverse is -63 mod 157 ≡ 94
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7511500920751010
    150092751199643101
    751643110801-1
    64310851031-16
    10810315-16-7
    10352036-7146
    5312-7146-153
    3211146-153299
    2120-153299-751
    So our multiplicative inverse is 299 mod 751 ≡ 299
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9561179070956010
    117907956123319101
    956319231801-2
    319318111-23
    31813180-23-956
    So our multiplicative inverse is 3 mod 956 ≡ 3
    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
    =  (154 × 717956 × 94 +
       26 × 150092 × 299 +
       69 × 117907 × 3)   mod 112719092
    = 87005629 (mod 112719092)


    So our answer is 87005629 (mod 112719092).


Verification

So we found that x ≡ 87005629
If this is correct, then the following statements (i.e. the original equations) are true:
549x (mod 157) ≡ 237 (mod 157)
23x (mod 751) ≡ 598 (mod 751)
501x (mod 956) ≡ 153 (mod 956)

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