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
621454116701-1
45416721201-13
167120147-13-4
120472263-411
4726121-411-15
26211511-1526
21541-1526-119
515026-119621
So our multiplicative inverse is -119 mod 621 ≡ 502
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
887348219101-2
34819111571-23
191157134-23-5
157344213-523
3421113-523-28
21131823-2851
13815-2851-79
851351-79130
5312-79130-209
3211130-209339
2120-209339-887
So our multiplicative inverse is 339 mod 887 ≡ 339
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1875800187010
580187319101
1871991601-9
1916131-910
16351-910-59
313010-59187
So our multiplicative inverse is -59 mod 187 ≡ 128
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 ≡ 806 × 454-1 (mod 621) ≡ 806 × 502 (mod 621) ≡ 341 (mod 621)
x ≡ 598 × 348-1 (mod 887) ≡ 598 × 339 (mod 887) ≡ 486 (mod 887)
x ≡ 551 × 580-1 (mod 187) ≡ 551 × 128 (mod 187) ≡ 29 (mod 187)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 621 × 887 × 187 = 103004649
  2. We calculate the numbers M1 to M3
    M1=M/m1=103004649/621=165869,   M2=M/m2=103004649/887=116127,   M3=M/m3=103004649/187=550827
  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
    6211658690621010
    16586962126762101
    6216210101-10
    6216201-10621
    So our multiplicative inverse is -10 mod 621 ≡ 611
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8871161270887010
    116127887130817101
    88781717001-1
    8177011471-112
    7047123-112-13
    47232112-1338
    231230-1338-887
    So our multiplicative inverse is 38 mod 887 ≡ 38
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1875508270187010
    5508271872945112101
    18711217501-1
    112751371-12
    753721-12-5
    3713702-5187
    So our multiplicative inverse is -5 mod 187 ≡ 182
    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
    =  (341 × 165869 × 611 +
       486 × 116127 × 38 +
       29 × 550827 × 182)   mod 103004649
    = 57085145 (mod 103004649)


    So our answer is 57085145 (mod 103004649).


Verification

So we found that x ≡ 57085145
If this is correct, then the following statements (i.e. the original equations) are true:
454x (mod 621) ≡ 806 (mod 621)
348x (mod 887) ≡ 598 (mod 887)
580x (mod 187) ≡ 551 (mod 187)

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