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
5099500509010
9505091441101
50944116801-1
441686331-17
683322-17-15
3321617-15247
2120-15247-509
So our multiplicative inverse is 247 mod 509 ≡ 247
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3213880321010
388321167101
3216745301-4
67531141-45
5314311-45-19
1411135-1924
11332-1924-91
321124-91115
2120-91115-321
So our multiplicative inverse is 115 mod 321 ≡ 115
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
48838919901-1
389993921-14
999217-14-5
9271314-569
7170-569-488
So our multiplicative inverse is 69 mod 488 ≡ 69
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 ≡ 911 × 950-1 (mod 509) ≡ 911 × 247 (mod 509) ≡ 39 (mod 509)
x ≡ 415 × 388-1 (mod 321) ≡ 415 × 115 (mod 321) ≡ 217 (mod 321)
x ≡ 992 × 389-1 (mod 488) ≡ 992 × 69 (mod 488) ≡ 128 (mod 488)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 509 × 321 × 488 = 79733832
  2. We calculate the numbers M1 to M3
    M1=M/m1=79733832/509=156648,   M2=M/m2=79733832/321=248392,   M3=M/m3=79733832/488=163389
  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
    5091566480509010
    156648509307385101
    509385112401-1
    3851243131-14
    1241397-14-37
    137164-3741
    7611-3741-78
    616041-78509
    So our multiplicative inverse is -78 mod 509 ≡ 431
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3212483920321010
    248392321773259101
    32125916201-1
    259624111-15
    621157-15-26
    117145-2631
    7413-2631-57
    431131-5788
    3130-5788-321
    So our multiplicative inverse is 88 mod 321 ≡ 88
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4881633890488010
    163389488334397101
    48839719101-1
    397914331-15
    9133225-15-11
    3325185-1116
    25831-1116-59
    818016-59488
    So our multiplicative inverse is -59 mod 488 ≡ 429
    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
    =  (39 × 156648 × 431 +
       217 × 248392 × 88 +
       128 × 163389 × 429)   mod 79733832
    = 2971072 (mod 79733832)


    So our answer is 2971072 (mod 79733832).


Verification

So we found that x ≡ 2971072
If this is correct, then the following statements (i.e. the original equations) are true:
950x (mod 509) ≡ 911 (mod 509)
388x (mod 321) ≡ 415 (mod 321)
389x (mod 488) ≡ 992 (mod 488)

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