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
97641097010
64197659101
975913801-1
59381211-12
3821117-12-3
2117142-35
17441-35-23
41405-2397
So our multiplicative inverse is -23 mod 97 ≡ 74
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5116060511010
606511195101
5119553601-5
95362231-511
3623113-511-16
231311011-1627
131013-1627-43
1033127-43156
3130-43156-511
So our multiplicative inverse is 156 mod 511 ≡ 156
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
70131726701-2
317674491-29
6749118-29-11
49182139-1131
181315-1131-42
1352331-42115
5312-42115-157
3211115-157272
2120-157272-701
So our multiplicative inverse is 272 mod 701 ≡ 272
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 ≡ 369 × 641-1 (mod 97) ≡ 369 × 74 (mod 97) ≡ 49 (mod 97)
x ≡ 686 × 606-1 (mod 511) ≡ 686 × 156 (mod 511) ≡ 217 (mod 511)
x ≡ 921 × 317-1 (mod 701) ≡ 921 × 272 (mod 701) ≡ 255 (mod 701)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 97 × 511 × 701 = 34746467
  2. We calculate the numbers M1 to M3
    M1=M/m1=34746467/97=358211,   M2=M/m2=34746467/511=67997,   M3=M/m3=34746467/701=49567
  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
    97358211097010
    35821197369287101
    978711001-1
    8710871-19
    10713-19-10
    73219-1029
    3130-1029-97
    So our multiplicative inverse is 29 mod 97 ≡ 29
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    511679970511010
    6799751113334101
    5113415101-15
    3413401-15511
    So our multiplicative inverse is -15 mod 511 ≡ 496
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    701495670701010
    4956770170497101
    701497120401-1
    4972042891-13
    20489226-13-7
    89263113-724
    261124-724-55
    1142324-55134
    4311-55134-189
    3130134-189701
    So our multiplicative inverse is -189 mod 701 ≡ 512
    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
    =  (49 × 358211 × 29 +
       217 × 67997 × 496 +
       255 × 49567 × 512)   mod 34746467
    = 18340518 (mod 34746467)


    So our answer is 18340518 (mod 34746467).


Verification

So we found that x ≡ 18340518
If this is correct, then the following statements (i.e. the original equations) are true:
641x (mod 97) ≡ 369 (mod 97)
606x (mod 511) ≡ 686 (mod 511)
317x (mod 701) ≡ 921 (mod 701)

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