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
87727834301-3
278436201-319
432023-319-41
2036219-41265
3211-41265-306
2120265-306877
So our multiplicative inverse is -306 mod 877 ≡ 571
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8418670841010
867841126101
8412632901-32
269281-3265
9811-3265-97
818065-97841
So our multiplicative inverse is -97 mod 841 ≡ 744
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
829356211701-2
356117351-27
1175232-27-163
52217-163333
2120-163333-829
So our multiplicative inverse is 333 mod 829 ≡ 333
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 ≡ 404 × 278-1 (mod 877) ≡ 404 × 571 (mod 877) ≡ 33 (mod 877)
x ≡ 999 × 867-1 (mod 841) ≡ 999 × 744 (mod 841) ≡ 653 (mod 841)
x ≡ 807 × 356-1 (mod 829) ≡ 807 × 333 (mod 829) ≡ 135 (mod 829)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 877 × 841 × 829 = 611434753
  2. We calculate the numbers M1 to M3
    M1=M/m1=611434753/877=697189,   M2=M/m2=611434753/841=727033,   M3=M/m3=611434753/829=737557
  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
    8776971890877010
    697189877794851101
    87785112601-1
    8512632191-133
    261917-133-34
    1972533-34101
    7512-34101-135
    5221101-135371
    2120-135371-877
    So our multiplicative inverse is 371 mod 877 ≡ 371
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8417270330841010
    727033841864409101
    84140922301-2
    4092317181-235
    231815-235-37
    1853335-37146
    5312-37146-183
    3211146-183329
    2120-183329-841
    So our multiplicative inverse is 329 mod 841 ≡ 329
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8297375570829010
    737557829889576101
    829576125301-1
    5762532701-13
    25370343-13-10
    70431273-1013
    4327116-1013-23
    271611113-2336
    161115-2336-59
    1152136-59154
    5150-59154-829
    So our multiplicative inverse is 154 mod 829 ≡ 154
    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
    =  (33 × 697189 × 371 +
       653 × 727033 × 329 +
       135 × 737557 × 154)   mod 611434753
    = 301266196 (mod 611434753)


    So our answer is 301266196 (mod 611434753).


Verification

So we found that x ≡ 301266196
If this is correct, then the following statements (i.e. the original equations) are true:
278x (mod 877) ≡ 404 (mod 877)
867x (mod 841) ≡ 999 (mod 841)
356x (mod 829) ≡ 807 (mod 829)

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