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
6857180685010
718685133101
68533202501-20
3325181-2021
25831-2021-83
818021-83685
So our multiplicative inverse is -83 mod 685 ≡ 602
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
661332132901-1
332329131-12
32931092-12-219
32112-219221
2120-219221-661
So our multiplicative inverse is 221 mod 661 ≡ 221
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5578690557010
8695571312101
557312124501-1
3122451671-12
24567344-12-7
67441232-79
4423121-79-16
2321129-1625
212101-1625-266
212025-266557
So our multiplicative inverse is -266 mod 557 ≡ 291
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 ≡ 947 × 718-1 (mod 685) ≡ 947 × 602 (mod 685) ≡ 174 (mod 685)
x ≡ 773 × 332-1 (mod 661) ≡ 773 × 221 (mod 661) ≡ 295 (mod 661)
x ≡ 456 × 869-1 (mod 557) ≡ 456 × 291 (mod 557) ≡ 130 (mod 557)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 685 × 661 × 557 = 252201245
  2. We calculate the numbers M1 to M3
    M1=M/m1=252201245/685=368177,   M2=M/m2=252201245/661=381545,   M3=M/m3=252201245/557=452785
  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
    6853681770685010
    368177685537332101
    68533222101-2
    3322115171-231
    211714-231-33
    1744131-33163
    4140-33163-685
    So our multiplicative inverse is 163 mod 685 ≡ 163
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6613815450661010
    381545661577148101
    66114846901-4
    148692101-49
    691069-49-58
    109119-5867
    9190-5867-661
    So our multiplicative inverse is 67 mod 661 ≡ 67
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5574527850557010
    452785557812501101
    55750115601-1
    501568531-19
    565313-19-10
    5331729-10179
    3211-10179-189
    2120179-189557
    So our multiplicative inverse is -189 mod 557 ≡ 368
    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
    =  (174 × 368177 × 163 +
       295 × 381545 × 67 +
       130 × 452785 × 368)   mod 252201245
    = 49111934 (mod 252201245)


    So our answer is 49111934 (mod 252201245).


Verification

So we found that x ≡ 49111934
If this is correct, then the following statements (i.e. the original equations) are true:
718x (mod 685) ≡ 947 (mod 685)
332x (mod 661) ≡ 773 (mod 661)
869x (mod 557) ≡ 456 (mod 557)

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