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
32130511601-1
305161911-120
161160-120-321
So our multiplicative inverse is 20 mod 321 ≡ 20
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3739638501-3
96851111-34
851178-34-31
118134-3135
8322-3135-101
321135-101136
2120-101136-373
So our multiplicative inverse is 136 mod 373 ≡ 136
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
79371079010
37179455101
795512401-1
5524271-13
24733-13-10
73213-1023
3130-1023-79
So our multiplicative inverse is 23 mod 79 ≡ 23
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 ≡ 224 × 305-1 (mod 321) ≡ 224 × 20 (mod 321) ≡ 307 (mod 321)
x ≡ 5 × 96-1 (mod 373) ≡ 5 × 136 (mod 373) ≡ 307 (mod 373)
x ≡ 145 × 371-1 (mod 79) ≡ 145 × 23 (mod 79) ≡ 17 (mod 79)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 321 × 373 × 79 = 9458907
  2. We calculate the numbers M1 to M3
    M1=M/m1=9458907/321=29467,   M2=M/m2=9458907/373=25359,   M3=M/m3=9458907/79=119733
  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
    321294670321010
    2946732191256101
    32125616501-1
    256653611-14
    656114-14-5
    6141514-579
    4140-579-321
    So our multiplicative inverse is 79 mod 321 ≡ 79
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    373253590373010
    2535937367368101
    3733681501-1
    36857331-174
    5312-174-75
    321174-75149
    2120-75149-373
    So our multiplicative inverse is 149 mod 373 ≡ 149
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    79119733079010
    11973379151548101
    794813101-1
    48311171-12
    3117114-12-3
    1714132-35
    14342-35-23
    32115-2328
    2120-2328-79
    So our multiplicative inverse is 28 mod 79 ≡ 28
    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
    =  (307 × 29467 × 79 +
       307 × 25359 × 149 +
       17 × 119733 × 28)   mod 9458907
    = 2035768 (mod 9458907)


    So our answer is 2035768 (mod 9458907).


Verification

So we found that x ≡ 2035768
If this is correct, then the following statements (i.e. the original equations) are true:
305x (mod 321) ≡ 224 (mod 321)
96x (mod 373) ≡ 5 (mod 373)
371x (mod 79) ≡ 145 (mod 79)

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