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
1372100137010
210137173101
1377316401-1
7364191-12
64971-12-15
91902-15137
So our multiplicative inverse is -15 mod 137 ≡ 122
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5152322901-22
239251-2245
9514-2245-67
541145-67112
4140-67112-515
So our multiplicative inverse is 112 mod 515 ≡ 112
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
544777501-77
75121-7778
5221-7778-233
212078-233544
So our multiplicative inverse is -233 mod 544 ≡ 311
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 ≡ 781 × 210-1 (mod 137) ≡ 781 × 122 (mod 137) ≡ 67 (mod 137)
x ≡ 623 × 23-1 (mod 515) ≡ 623 × 112 (mod 515) ≡ 251 (mod 515)
x ≡ 961 × 7-1 (mod 544) ≡ 961 × 311 (mod 544) ≡ 215 (mod 544)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 137 × 515 × 544 = 38381920
  2. We calculate the numbers M1 to M3
    M1=M/m1=38381920/137=280160,   M2=M/m2=38381920/515=74528,   M3=M/m3=38381920/544=70555
  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
    1372801600137010
    2801601372044132101
    1371321501-1
    13252621-127
    5221-127-55
    212027-55137
    So our multiplicative inverse is -55 mod 137 ≡ 82
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    515745280515010
    74528515144368101
    515368114701-1
    3681472741-13
    14774173-13-4
    7473113-47
    731730-47-515
    So our multiplicative inverse is 7 mod 515 ≡ 7
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    544705550544010
    70555544129379101
    544379116501-1
    3791652491-13
    16549318-13-10
    49182133-1023
    181315-1023-33
    1352323-3389
    5312-3389-122
    321189-122211
    2120-122211-544
    So our multiplicative inverse is 211 mod 544 ≡ 211
    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
    =  (67 × 280160 × 82 +
       251 × 74528 × 7 +
       215 × 70555 × 211)   mod 38381920
    = 34750391 (mod 38381920)


    So our answer is 34750391 (mod 38381920).


Verification

So we found that x ≡ 34750391
If this is correct, then the following statements (i.e. the original equations) are true:
210x (mod 137) ≡ 781 (mod 137)
23x (mod 515) ≡ 623 (mod 515)
7x (mod 544) ≡ 961 (mod 544)

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