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
809576123301-1
57623321101-13
233110213-13-7
11013863-759
13621-759-125
616059-125809
So our multiplicative inverse is -125 mod 809 ≡ 684
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1633410163010
341163215101
16315101301-10
1513121-1011
13261-1011-76
212011-76163
So our multiplicative inverse is -76 mod 163 ≡ 87
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1011380101010
138101137101
1013722701-2
37271101-23
271027-23-8
107133-811
7321-811-30
313011-30101
So our multiplicative inverse is -30 mod 101 ≡ 71
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 ≡ 347 × 576-1 (mod 809) ≡ 347 × 684 (mod 809) ≡ 311 (mod 809)
x ≡ 820 × 341-1 (mod 163) ≡ 820 × 87 (mod 163) ≡ 109 (mod 163)
x ≡ 502 × 138-1 (mod 101) ≡ 502 × 71 (mod 101) ≡ 90 (mod 101)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 809 × 163 × 101 = 13318567
  2. We calculate the numbers M1 to M3
    M1=M/m1=13318567/809=16463,   M2=M/m2=13318567/163=81709,   M3=M/m3=13318567/101=131867
  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
    809164630809010
    1646380920283101
    809283224301-2
    2832431401-23
    2434063-23-20
    4031313-20263
    3130-20263-809
    So our multiplicative inverse is 263 mod 809 ≡ 263
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    163817090163010
    8170916350146101
    1634632501-3
    46251211-34
    252114-34-7
    214514-739
    4140-739-163
    So our multiplicative inverse is 39 mod 163 ≡ 39
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1011318670101010
    131867101130562101
    1016213901-1
    62391231-12
    3923116-12-3
    2316172-35
    16722-35-13
    72315-1344
    2120-1344-101
    So our multiplicative inverse is 44 mod 101 ≡ 44
    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
    =  (311 × 16463 × 263 +
       109 × 81709 × 39 +
       90 × 131867 × 44)   mod 13318567
    = 5214316 (mod 13318567)


    So our answer is 5214316 (mod 13318567).


Verification

So we found that x ≡ 5214316
If this is correct, then the following statements (i.e. the original equations) are true:
576x (mod 809) ≡ 347 (mod 809)
341x (mod 163) ≡ 820 (mod 163)
138x (mod 101) ≡ 502 (mod 101)

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