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
5877270587010
7275871140101
58714042701-4
14027551-421
27552-421-109
522121-109239
2120-109239-587
So our multiplicative inverse is 239 mod 587 ≡ 239
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4891048901-48
109111-4849
9190-4849-489
So our multiplicative inverse is 49 mod 489 ≡ 49
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2576860257010
6862572172101
25717218501-1
17285221-13
852421-13-127
21203-127257
So our multiplicative inverse is -127 mod 257 ≡ 130
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 ≡ 290 × 727-1 (mod 587) ≡ 290 × 239 (mod 587) ≡ 44 (mod 587)
x ≡ 182 × 10-1 (mod 489) ≡ 182 × 49 (mod 489) ≡ 116 (mod 489)
x ≡ 687 × 686-1 (mod 257) ≡ 687 × 130 (mod 257) ≡ 131 (mod 257)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 587 × 489 × 257 = 73770051
  2. We calculate the numbers M1 to M3
    M1=M/m1=73770051/587=125673,   M2=M/m2=73770051/489=150859,   M3=M/m3=73770051/257=287043
  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
    5871256730587010
    12567358721455101
    58755103701-10
    55371181-1011
    371821-1011-32
    18118011-32587
    So our multiplicative inverse is -32 mod 587 ≡ 555
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4891508590489010
    150859489308247101
    489247124201-1
    247242151-12
    2425482-12-97
    52212-97196
    2120-97196-489
    So our multiplicative inverse is 196 mod 489 ≡ 196
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2572870430257010
    2870432571116231101
    25723112601-1
    231268231-19
    262313-19-10
    233729-1079
    3211-1079-89
    212079-89257
    So our multiplicative inverse is -89 mod 257 ≡ 168
    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
    =  (44 × 125673 × 555 +
       116 × 150859 × 196 +
       131 × 287043 × 168)   mod 73770051
    = 53888405 (mod 73770051)


    So our answer is 53888405 (mod 73770051).


Verification

So we found that x ≡ 53888405
If this is correct, then the following statements (i.e. the original equations) are true:
727x (mod 587) ≡ 290 (mod 587)
10x (mod 489) ≡ 182 (mod 489)
686x (mod 257) ≡ 687 (mod 257)

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