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
844291226201-2
2912621291-23
2622991-23-29
2912903-29844
So our multiplicative inverse is -29 mod 844 ≡ 815
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3597850359010
785359267101
3596752401-5
67242191-511
241915-511-16
1953411-1659
5411-1659-75
414059-75359
So our multiplicative inverse is -75 mod 359 ≡ 284
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
97301097010
30197310101
97109701-9
107131-910
7321-910-29
313010-2997
So our multiplicative inverse is -29 mod 97 ≡ 68
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 ≡ 367 × 291-1 (mod 844) ≡ 367 × 815 (mod 844) ≡ 329 (mod 844)
x ≡ 824 × 785-1 (mod 359) ≡ 824 × 284 (mod 359) ≡ 307 (mod 359)
x ≡ 86 × 301-1 (mod 97) ≡ 86 × 68 (mod 97) ≡ 28 (mod 97)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 844 × 359 × 97 = 29390612
  2. We calculate the numbers M1 to M3
    M1=M/m1=29390612/844=34823,   M2=M/m2=29390612/359=81868,   M3=M/m3=29390612/97=302996
  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
    844348230844010
    3482384441219101
    844219318701-3
    2191871321-34
    18732527-34-23
    3227154-2327
    27552-2327-158
    522127-158343
    2120-158343-844
    So our multiplicative inverse is 343 mod 844 ≡ 343
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    359818680359010
    8186835922816101
    3591622701-22
    167221-2245
    7231-2245-157
    212045-157359
    So our multiplicative inverse is -157 mod 359 ≡ 202
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    97302996097010
    30299697312365101
    976513201-1
    6532211-13
    321320-13-97
    So our multiplicative inverse is 3 mod 97 ≡ 3
    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
    =  (329 × 34823 × 343 +
       307 × 81868 × 202 +
       28 × 302996 × 3)   mod 29390612
    = 9167013 (mod 29390612)


    So our answer is 9167013 (mod 29390612).


Verification

So we found that x ≡ 9167013
If this is correct, then the following statements (i.e. the original equations) are true:
291x (mod 844) ≡ 367 (mod 844)
785x (mod 359) ≡ 824 (mod 359)
301x (mod 97) ≡ 86 (mod 97)

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