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
653244216501-2
2441651791-23
1657927-23-8
7971123-891
7231-891-281
212091-281653
So our multiplicative inverse is -281 mod 653 ≡ 372
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
67158113301-11
58331251-1112
332518-1112-23
2583112-2381
8180-2381-671
So our multiplicative inverse is 81 mod 671 ≡ 81
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
38315726901-2
157692191-25
6919312-25-17
1912175-1722
12715-1722-39
751222-3961
5221-3961-161
212061-161383
So our multiplicative inverse is -161 mod 383 ≡ 222
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 ≡ 620 × 244-1 (mod 653) ≡ 620 × 372 (mod 653) ≡ 131 (mod 653)
x ≡ 238 × 58-1 (mod 671) ≡ 238 × 81 (mod 671) ≡ 490 (mod 671)
x ≡ 960 × 157-1 (mod 383) ≡ 960 × 222 (mod 383) ≡ 172 (mod 383)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 653 × 671 × 383 = 167816429
  2. We calculate the numbers M1 to M3
    M1=M/m1=167816429/653=256993,   M2=M/m2=167816429/671=250099,   M3=M/m3=167816429/383=438163
  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
    6532569930653010
    256993653393364101
    653364128901-1
    3642891751-12
    28975364-12-7
    75641112-79
    641159-79-52
    119129-5261
    9241-5261-296
    212061-296653
    So our multiplicative inverse is -296 mod 653 ≡ 357
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6712500990671010
    250099671372487101
    671487118401-1
    48718421191-13
    184119165-13-4
    119651543-47
    6554111-47-11
    54114107-1151
    111011-1151-62
    10110051-62671
    So our multiplicative inverse is -62 mod 671 ≡ 609
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3834381630383010
    438163383114411101
    3831134901-34
    119121-3435
    9241-3435-174
    212035-174383
    So our multiplicative inverse is -174 mod 383 ≡ 209
    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
    =  (131 × 256993 × 357 +
       490 × 250099 × 609 +
       172 × 438163 × 209)   mod 167816429
    = 33896055 (mod 167816429)


    So our answer is 33896055 (mod 167816429).


Verification

So we found that x ≡ 33896055
If this is correct, then the following statements (i.e. the original equations) are true:
244x (mod 653) ≡ 620 (mod 653)
58x (mod 671) ≡ 238 (mod 671)
157x (mod 383) ≡ 960 (mod 383)

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