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
703457124601-1
45724612111-12
246211135-12-3
21135612-320
351350-320-703
So our multiplicative inverse is 20 mod 703 ≡ 20
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2635850263010
585263259101
2635942701-4
5927251-49
27552-49-49
52219-49107
2120-49107-263
So our multiplicative inverse is 107 mod 263 ≡ 107
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
22320811501-1
2081513131-114
151312-114-15
1326114-15104
2120-15104-223
So our multiplicative inverse is 104 mod 223 ≡ 104
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 ≡ 378 × 457-1 (mod 703) ≡ 378 × 20 (mod 703) ≡ 530 (mod 703)
x ≡ 533 × 585-1 (mod 263) ≡ 533 × 107 (mod 263) ≡ 223 (mod 263)
x ≡ 392 × 208-1 (mod 223) ≡ 392 × 104 (mod 223) ≡ 182 (mod 223)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 703 × 263 × 223 = 41230247
  2. We calculate the numbers M1 to M3
    M1=M/m1=41230247/703=58649,   M2=M/m2=41230247/263=156769,   M3=M/m3=41230247/223=184889
  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
    703586490703010
    5864970383300101
    703300210301-2
    3001032941-25
    1039419-25-7
    9491045-775
    9421-775-157
    414075-157703
    So our multiplicative inverse is -157 mod 703 ≡ 546
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2631567690263010
    15676926359621101
    26321121101-12
    21111101-1213
    111011-1213-25
    10110013-25263
    So our multiplicative inverse is -25 mod 263 ≡ 238
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2231848890223010
    18488922382922101
    2232210301-10
    223711-1071
    3130-1071-223
    So our multiplicative inverse is 71 mod 223 ≡ 71
    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
    =  (530 × 58649 × 546 +
       223 × 156769 × 238 +
       182 × 184889 × 71)   mod 41230247
    = 15845447 (mod 41230247)


    So our answer is 15845447 (mod 41230247).


Verification

So we found that x ≡ 15845447
If this is correct, then the following statements (i.e. the original equations) are true:
457x (mod 703) ≡ 378 (mod 703)
585x (mod 263) ≡ 533 (mod 263)
208x (mod 223) ≡ 392 (mod 223)

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