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
907231321401-3
2312141171-34
214171210-34-51
1710174-5155
10713-5155-106
732155-106267
3130-106267-907
So our multiplicative inverse is 267 mod 907 ≡ 267
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
39117524101-2
175414111-29
411138-29-29
118139-2938
8322-2938-105
321138-105143
2120-105143-391
So our multiplicative inverse is 143 mod 391 ≡ 143
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
865763110201-1
7631027491-18
1024924-18-17
4941218-17212
4140-17212-865
So our multiplicative inverse is 212 mod 865 ≡ 212
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 ≡ 894 × 231-1 (mod 907) ≡ 894 × 267 (mod 907) ≡ 157 (mod 907)
x ≡ 246 × 175-1 (mod 391) ≡ 246 × 143 (mod 391) ≡ 379 (mod 391)
x ≡ 772 × 763-1 (mod 865) ≡ 772 × 212 (mod 865) ≡ 179 (mod 865)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 907 × 391 × 865 = 306761005
  2. We calculate the numbers M1 to M3
    M1=M/m1=306761005/907=338215,   M2=M/m2=306761005/391=784555,   M3=M/m3=306761005/865=354637
  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
    9073382150907010
    338215907372811101
    90781119601-1
    811968431-19
    9643210-19-19
    4310439-1985
    10331-1985-274
    313085-274907
    So our multiplicative inverse is -274 mod 907 ≡ 633
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3917845550391010
    7845553912006209101
    391209118201-1
    2091821271-12
    18227620-12-13
    2720172-1315
    20726-1315-43
    761115-4358
    6160-4358-391
    So our multiplicative inverse is 58 mod 391 ≡ 58
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8653546370865010
    354637865409852101
    86585211301-1
    852136571-166
    13716-166-67
    761166-67133
    6160-67133-865
    So our multiplicative inverse is 133 mod 865 ≡ 133
    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
    =  (157 × 338215 × 633 +
       379 × 784555 × 58 +
       179 × 354637 × 133)   mod 306761005
    = 96202019 (mod 306761005)


    So our answer is 96202019 (mod 306761005).


Verification

So we found that x ≡ 96202019
If this is correct, then the following statements (i.e. the original equations) are true:
231x (mod 907) ≡ 894 (mod 907)
175x (mod 391) ≡ 246 (mod 391)
763x (mod 865) ≡ 772 (mod 865)

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