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
8279140827010
914827187101
8278794401-9
87441431-910
444311-910-19
43143010-19827
So our multiplicative inverse is -19 mod 827 ≡ 808
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
839554128501-1
55428512691-12
285269116-12-3
2691616132-350
161313-350-53
1334150-53262
3130-53262-839
So our multiplicative inverse is 262 mod 839 ≡ 262
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5037920503010
7925031289101
503289121401-1
2892141751-12
21475264-12-5
75641112-57
641159-57-40
119127-4047
9241-4047-228
212047-228503
So our multiplicative inverse is -228 mod 503 ≡ 275
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 ≡ 232 × 914-1 (mod 827) ≡ 232 × 808 (mod 827) ≡ 554 (mod 827)
x ≡ 444 × 554-1 (mod 839) ≡ 444 × 262 (mod 839) ≡ 546 (mod 839)
x ≡ 838 × 792-1 (mod 503) ≡ 838 × 275 (mod 503) ≡ 76 (mod 503)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 827 × 839 × 503 = 349008059
  2. We calculate the numbers M1 to M3
    M1=M/m1=349008059/827=422017,   M2=M/m2=349008059/839=415981,   M3=M/m3=349008059/503=693853
  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
    8274220170827010
    422017827510247101
    82724738601-3
    247862751-37
    8675111-37-10
    7511697-1067
    11912-1067-77
    924167-77375
    2120-77375-827
    So our multiplicative inverse is 375 mod 827 ≡ 375
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8394159810839010
    415981839495676101
    839676116301-1
    6761634241-15
    16324619-15-31
    2419155-3136
    19534-3136-139
    541136-139175
    4140-139175-839
    So our multiplicative inverse is 175 mod 839 ≡ 175
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5036938530503010
    6938535031379216101
    50321627101-2
    21671331-27
    713232-27-163
    32117-163170
    2120-163170-503
    So our multiplicative inverse is 170 mod 503 ≡ 170
    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
    =  (554 × 422017 × 375 +
       546 × 415981 × 175 +
       76 × 693853 × 170)   mod 349008059
    = 272454050 (mod 349008059)


    So our answer is 272454050 (mod 349008059).


Verification

So we found that x ≡ 272454050
If this is correct, then the following statements (i.e. the original equations) are true:
914x (mod 827) ≡ 232 (mod 827)
554x (mod 839) ≡ 444 (mod 839)
792x (mod 503) ≡ 838 (mod 503)

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