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
983695128801-1
69528821191-13
288119250-13-7
119502193-717
5019212-717-41
19121717-4158
12715-4158-99
751258-99157
5221-99157-413
2120157-413983
So our multiplicative inverse is -413 mod 983 ≡ 570
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
989202418101-4
2021811211-45
18121813-45-44
2113185-4449
13815-4449-93
851349-93142
5312-93142-235
3211142-235377
2120-235377-989
So our multiplicative inverse is 377 mod 989 ≡ 377
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4898480489010
8484891359101
489359113001-1
3591302991-13
13099131-13-4
9931363-415
31651-415-79
616015-79489
So our multiplicative inverse is -79 mod 489 ≡ 410
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 ≡ 258 × 695-1 (mod 983) ≡ 258 × 570 (mod 983) ≡ 593 (mod 983)
x ≡ 209 × 202-1 (mod 989) ≡ 209 × 377 (mod 989) ≡ 662 (mod 989)
x ≡ 428 × 848-1 (mod 489) ≡ 428 × 410 (mod 489) ≡ 418 (mod 489)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 983 × 989 × 489 = 475399443
  2. We calculate the numbers M1 to M3
    M1=M/m1=475399443/983=483621,   M2=M/m2=475399443/989=480687,   M3=M/m3=475399443/489=972187
  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
    9834836210983010
    483621983491968101
    98396811501-1
    968156481-165
    15817-165-66
    871165-66131
    7170-66131-983
    So our multiplicative inverse is 131 mod 983 ≡ 131
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9894806870989010
    48068798948633101
    98933293201-29
    3332111-2930
    321320-2930-989
    So our multiplicative inverse is 30 mod 989 ≡ 30
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4899721870489010
    972187489198855101
    4895584901-8
    5549161-89
    49681-89-80
    61609-80489
    So our multiplicative inverse is -80 mod 489 ≡ 409
    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
    =  (593 × 483621 × 131 +
       662 × 480687 × 30 +
       418 × 972187 × 409)   mod 475399443
    = 343657393 (mod 475399443)


    So our answer is 343657393 (mod 475399443).


Verification

So we found that x ≡ 343657393
If this is correct, then the following statements (i.e. the original equations) are true:
695x (mod 983) ≡ 258 (mod 983)
202x (mod 989) ≡ 209 (mod 989)
848x (mod 489) ≡ 428 (mod 489)

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