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
83480083010
48083565101
836511801-1
65183111-14
181117-14-5
117144-59
7413-59-14
43119-1423
3130-1423-83
So our multiplicative inverse is 23 mod 83 ≡ 23
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1994200199010
420199222101
199229101-9
2212201-9199
So our multiplicative inverse is -9 mod 199 ≡ 190
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
985533145201-1
5334521811-12
45281547-12-11
81471342-1113
4734113-1113-24
34132813-2461
13815-2461-85
851361-85146
5312-85146-231
3211146-231377
2120-231377-985
So our multiplicative inverse is 377 mod 985 ≡ 377
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 ≡ 311 × 480-1 (mod 83) ≡ 311 × 23 (mod 83) ≡ 15 (mod 83)
x ≡ 350 × 420-1 (mod 199) ≡ 350 × 190 (mod 199) ≡ 34 (mod 199)
x ≡ 263 × 533-1 (mod 985) ≡ 263 × 377 (mod 985) ≡ 651 (mod 985)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 83 × 199 × 985 = 16269245
  2. We calculate the numbers M1 to M3
    M1=M/m1=16269245/83=196015,   M2=M/m2=16269245/199=81755,   M3=M/m3=16269245/985=16517
  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
    83196015083010
    19601583236152101
    835213101-1
    52311211-12
    3121110-12-3
    2110212-38
    101100-38-83
    So our multiplicative inverse is 8 mod 83 ≡ 8
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    199817550199010
    81755199410165101
    19916513401-1
    165344291-15
    342915-15-6
    295545-635
    5411-635-41
    414035-41199
    So our multiplicative inverse is -41 mod 199 ≡ 158
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    985165170985010
    1651798516757101
    985757122801-1
    7572283731-14
    2287339-14-13
    739814-13108
    9190-13108-985
    So our multiplicative inverse is 108 mod 985 ≡ 108
    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
    =  (15 × 196015 × 8 +
       34 × 81755 × 158 +
       651 × 16517 × 108)   mod 16269245
    = 13331641 (mod 16269245)


    So our answer is 13331641 (mod 16269245).


Verification

So we found that x ≡ 13331641
If this is correct, then the following statements (i.e. the original equations) are true:
480x (mod 83) ≡ 311 (mod 83)
420x (mod 199) ≡ 350 (mod 199)
533x (mod 985) ≡ 263 (mod 985)

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