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
3199380319010
9383192300101
31930011901-1
3001915151-116
191514-116-17
1543316-1767
4311-1767-84
313067-84319
So our multiplicative inverse is -84 mod 319 ≡ 235
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
89386113201-1
8613226291-127
322913-127-28
2939227-28279
3211-28279-307
2120279-307893
So our multiplicative inverse is -307 mod 893 ≡ 586
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5559170555010
9175551362101
555362119301-1
36219311691-12
193169124-12-3
16924712-323
241240-323-555
So our multiplicative inverse is 23 mod 555 ≡ 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 ≡ 166 × 938-1 (mod 319) ≡ 166 × 235 (mod 319) ≡ 92 (mod 319)
x ≡ 859 × 861-1 (mod 893) ≡ 859 × 586 (mod 893) ≡ 615 (mod 893)
x ≡ 530 × 917-1 (mod 555) ≡ 530 × 23 (mod 555) ≡ 535 (mod 555)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 319 × 893 × 555 = 158101185
  2. We calculate the numbers M1 to M3
    M1=M/m1=158101185/319=495615,   M2=M/m2=158101185/893=177045,   M3=M/m3=158101185/555=284867
  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
    3194956150319010
    4956153191553208101
    319208111101-1
    2081111971-12
    11197114-12-3
    97146132-320
    141311-320-23
    13113020-23319
    So our multiplicative inverse is -23 mod 319 ≡ 296
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8931770450893010
    177045893198231101
    893231320001-3
    2312001311-34
    20031614-34-27
    3114234-2758
    14342-2758-259
    321158-259317
    2120-259317-893
    So our multiplicative inverse is 317 mod 893 ≡ 317
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5552848670555010
    284867555513152101
    55515239901-3
    152991531-34
    9953146-34-7
    5346174-711
    46764-711-73
    741311-7384
    4311-7384-157
    313084-157555
    So our multiplicative inverse is -157 mod 555 ≡ 398
    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
    =  (92 × 495615 × 296 +
       615 × 177045 × 317 +
       535 × 284867 × 398)   mod 158101185
    = 53611870 (mod 158101185)


    So our answer is 53611870 (mod 158101185).


Verification

So we found that x ≡ 53611870
If this is correct, then the following statements (i.e. the original equations) are true:
938x (mod 319) ≡ 166 (mod 319)
861x (mod 893) ≡ 859 (mod 893)
917x (mod 555) ≡ 530 (mod 555)

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