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
983280314301-3
28014311371-34
14313716-34-7
13762254-7158
6511-7158-165
5150158-165983
So our multiplicative inverse is -165 mod 983 ≡ 818
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5899260589010
9265891337101
589337125201-1
3372521851-12
25285282-12-5
8582132-57
823271-57-194
31307-194589
So our multiplicative inverse is -194 mod 589 ≡ 395
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
87133261301-26
3313271-2653
13716-2653-79
761153-79132
6160-79132-871
So our multiplicative inverse is 132 mod 871 ≡ 132
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 ≡ 503 × 280-1 (mod 983) ≡ 503 × 818 (mod 983) ≡ 560 (mod 983)
x ≡ 278 × 926-1 (mod 589) ≡ 278 × 395 (mod 589) ≡ 256 (mod 589)
x ≡ 400 × 33-1 (mod 871) ≡ 400 × 132 (mod 871) ≡ 540 (mod 871)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 983 × 589 × 871 = 504297677
  2. We calculate the numbers M1 to M3
    M1=M/m1=504297677/983=513019,   M2=M/m2=504297677/589=856193,   M3=M/m3=504297677/871=578987
  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
    9835130190983010
    513019983521876101
    983876110701-1
    8761078201-19
    1072057-19-46
    207269-46101
    7611-46101-147
    6160101-147983
    So our multiplicative inverse is -147 mod 983 ≡ 836
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5898561930589010
    8561935891453376101
    589376121301-1
    37621311631-12
    213163150-12-3
    163503132-311
    5013311-311-36
    13111211-3647
    11251-3647-271
    212047-271589
    So our multiplicative inverse is -271 mod 589 ≡ 318
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8715789870871010
    578987871664643101
    871643122801-1
    64322821871-13
    228187141-13-4
    187414233-419
    4123118-419-23
    23181519-2342
    18533-2342-149
    531242-149191
    3211-149191-340
    2120191-340871
    So our multiplicative inverse is -340 mod 871 ≡ 531
    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
    =  (560 × 513019 × 836 +
       256 × 856193 × 318 +
       540 × 578987 × 531)   mod 504297677
    = 341957753 (mod 504297677)


    So our answer is 341957753 (mod 504297677).


Verification

So we found that x ≡ 341957753
If this is correct, then the following statements (i.e. the original equations) are true:
280x (mod 983) ≡ 503 (mod 983)
926x (mod 589) ≡ 278 (mod 589)
33x (mod 871) ≡ 400 (mod 871)

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