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
1379090137010
909137687101
1378715001-1
87501371-12
5037113-12-3
37132112-38
131112-38-11
112518-1163
2120-1163-137
So our multiplicative inverse is 63 mod 137 ≡ 63
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6049330604010
9336041329101
604329127501-1
3292751541-12
2755455-12-11
5451042-11112
5411-11112-123
4140112-123604
So our multiplicative inverse is -123 mod 604 ≡ 481
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
35926619301-1
266932801-13
9380113-13-4
8013623-427
13261-427-166
212027-166359
So our multiplicative inverse is -166 mod 359 ≡ 193
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 ≡ 373 × 909-1 (mod 137) ≡ 373 × 63 (mod 137) ≡ 72 (mod 137)
x ≡ 314 × 933-1 (mod 604) ≡ 314 × 481 (mod 604) ≡ 34 (mod 604)
x ≡ 359 × 266-1 (mod 359) ≡ 359 × 193 (mod 359) ≡ 0 (mod 359)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 137 × 604 × 359 = 29706532
  2. We calculate the numbers M1 to M3
    M1=M/m1=29706532/137=216836,   M2=M/m2=29706532/604=49183,   M3=M/m3=29706532/359=82748
  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
    1372168360137010
    2168361371582102101
    13710213501-1
    102352321-13
    353213-13-4
    3231023-443
    3211-443-47
    212043-47137
    So our multiplicative inverse is -47 mod 137 ≡ 90
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    604491830604010
    4918360481259101
    60425928601-2
    25986311-27
    861860-27-604
    So our multiplicative inverse is 7 mod 604 ≡ 7
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    359827480359010
    82748359230178101
    3591782301-2
    17835911-2119
    3130-2119-359
    So our multiplicative inverse is 119 mod 359 ≡ 119
    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
    =  (72 × 216836 × 90 +
       34 × 49183 × 7 +
       0 × 82748 × 119)   mod 29706532
    = 20595830 (mod 29706532)


    So our answer is 20595830 (mod 29706532).


Verification

So we found that x ≡ 20595830
If this is correct, then the following statements (i.e. the original equations) are true:
909x (mod 137) ≡ 373 (mod 137)
933x (mod 604) ≡ 314 (mod 604)
266x (mod 359) ≡ 359 (mod 359)

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