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
967353226101-2
3532611921-23
26192277-23-8
92771153-811
771552-811-63
1527111-63452
2120-63452-967
So our multiplicative inverse is 452 mod 967 ≡ 452
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1252170125010
217125192101
1259213301-1
92332261-13
332617-13-4
267353-415
7512-415-19
522115-1953
2120-1953-125
So our multiplicative inverse is 53 mod 125 ≡ 53
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8699360869010
936869167101
86967126501-12
6765121-1213
652321-1213-428
212013-428869
So our multiplicative inverse is -428 mod 869 ≡ 441
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 ≡ 271 × 353-1 (mod 967) ≡ 271 × 452 (mod 967) ≡ 650 (mod 967)
x ≡ 566 × 217-1 (mod 125) ≡ 566 × 53 (mod 125) ≡ 123 (mod 125)
x ≡ 896 × 936-1 (mod 869) ≡ 896 × 441 (mod 869) ≡ 610 (mod 869)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 967 × 125 × 869 = 105040375
  2. We calculate the numbers M1 to M3
    M1=M/m1=105040375/967=108625,   M2=M/m2=105040375/125=840323,   M3=M/m3=105040375/869=120875
  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
    9671086250967010
    108625967112321101
    9673213401-3
    32148011-3241
    4140-3241-967
    So our multiplicative inverse is 241 mod 967 ≡ 241
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1258403230125010
    840323125672273101
    1257315201-1
    73521211-12
    5221210-12-5
    2110212-512
    101100-512-125
    So our multiplicative inverse is 12 mod 125 ≡ 12
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8691208750869010
    12087586913984101
    86984102901-10
    84292261-1021
    292613-1021-31
    2638221-31269
    3211-31269-300
    2120269-300869
    So our multiplicative inverse is -300 mod 869 ≡ 569
    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
    =  (650 × 108625 × 241 +
       123 × 840323 × 12 +
       610 × 120875 × 569)   mod 105040375
    = 22791873 (mod 105040375)


    So our answer is 22791873 (mod 105040375).


Verification

So we found that x ≡ 22791873
If this is correct, then the following statements (i.e. the original equations) are true:
353x (mod 967) ≡ 271 (mod 967)
217x (mod 125) ≡ 566 (mod 125)
936x (mod 869) ≡ 896 (mod 869)

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