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
503955801-55
98111-5556
8180-5556-503
So our multiplicative inverse is 56 mod 503 ≡ 56
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
874315224401-2
3152441711-23
24471331-23-11
7131293-1125
31934-1125-86
942125-86197
4140-86197-874
So our multiplicative inverse is 197 mod 874 ≡ 197
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1517870151010
787151532101
1513242301-4
3223191-45
23925-45-14
95145-1419
5411-1419-33
414019-33151
So our multiplicative inverse is -33 mod 151 ≡ 118
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 ≡ 761 × 9-1 (mod 503) ≡ 761 × 56 (mod 503) ≡ 364 (mod 503)
x ≡ 513 × 315-1 (mod 874) ≡ 513 × 197 (mod 874) ≡ 551 (mod 874)
x ≡ 213 × 787-1 (mod 151) ≡ 213 × 118 (mod 151) ≡ 68 (mod 151)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 503 × 874 × 151 = 66382922
  2. We calculate the numbers M1 to M3
    M1=M/m1=66382922/503=131974,   M2=M/m2=66382922/874=75953,   M3=M/m3=66382922/151=439622
  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
    5031319740503010
    131974503262188101
    503188212701-2
    1881271611-23
    1276125-23-8
    6151213-899
    5150-899-503
    So our multiplicative inverse is 99 mod 503 ≡ 99
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    874759530874010
    7595387486789101
    87478918501-1
    789859241-110
    8524313-110-31
    241311110-3141
    131112-3141-72
    1125141-72401
    2120-72401-874
    So our multiplicative inverse is 401 mod 874 ≡ 401
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1514396220151010
    439622151291161101
    1516122901-2
    6129231-25
    29392-25-47
    32115-4752
    2120-4752-151
    So our multiplicative inverse is 52 mod 151 ≡ 52
    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
    =  (364 × 131974 × 99 +
       551 × 75953 × 401 +
       68 × 439622 × 52)   mod 66382922
    = 57335825 (mod 66382922)


    So our answer is 57335825 (mod 66382922).


Verification

So we found that x ≡ 57335825
If this is correct, then the following statements (i.e. the original equations) are true:
9x (mod 503) ≡ 761 (mod 503)
315x (mod 874) ≡ 513 (mod 874)
787x (mod 151) ≡ 213 (mod 151)

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