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
8639580863010
958863195101
863959801-9
9581171-9100
8711-9100-109
7170100-109863
So our multiplicative inverse is -109 mod 863 ≡ 754
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6617220661010
722661161101
66161105101-10
61511101-1011
511051-1011-65
10110011-65661
So our multiplicative inverse is -65 mod 661 ≡ 596
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3135680313010
5683131255101
31325515801-1
255584231-15
5823212-15-11
23121115-1116
121111-1116-27
11111016-27313
So our multiplicative inverse is -27 mod 313 ≡ 286
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 ≡ 304 × 958-1 (mod 863) ≡ 304 × 754 (mod 863) ≡ 521 (mod 863)
x ≡ 431 × 722-1 (mod 661) ≡ 431 × 596 (mod 661) ≡ 408 (mod 661)
x ≡ 46 × 568-1 (mod 313) ≡ 46 × 286 (mod 313) ≡ 10 (mod 313)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 863 × 661 × 313 = 178548659
  2. We calculate the numbers M1 to M3
    M1=M/m1=178548659/863=206893,   M2=M/m2=178548659/661=270119,   M3=M/m3=178548659/313=570443
  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
    8632068930863010
    206893863239636101
    863636122701-1
    63622721821-13
    227182145-13-4
    18245423-419
    452221-419-422
    212019-422863
    So our multiplicative inverse is -422 mod 863 ≡ 441
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6612701190661010
    270119661408431101
    661431123001-1
    43123012011-12
    230201129-12-3
    201296272-320
    292712-320-23
    27213120-23319
    2120-23319-661
    So our multiplicative inverse is 319 mod 661 ≡ 319
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3135704430313010
    5704433131822157101
    313157115601-1
    157156111-12
    15611560-12-313
    So our multiplicative inverse is 2 mod 313 ≡ 2
    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
    =  (521 × 206893 × 441 +
       408 × 270119 × 319 +
       10 × 570443 × 2)   mod 178548659
    = 35850404 (mod 178548659)


    So our answer is 35850404 (mod 178548659).


Verification

So we found that x ≡ 35850404
If this is correct, then the following statements (i.e. the original equations) are true:
958x (mod 863) ≡ 304 (mod 863)
722x (mod 661) ≡ 431 (mod 661)
568x (mod 313) ≡ 46 (mod 313)

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