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
811643116801-1
64316831391-14
168139129-14-5
139294234-524
292316-524-29
2363524-29111
6511-29111-140
5150111-140811
So our multiplicative inverse is -140 mod 811 ≡ 671
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3435340343010
5343431191101
343191115201-1
1911521391-12
15239335-12-7
3935142-79
35483-79-79
43119-7988
3130-7988-343
So our multiplicative inverse is 88 mod 343 ≡ 88
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
839337216501-2
337165271-25
1657234-25-117
74135-117122
4311-117122-239
3130122-239839
So our multiplicative inverse is -239 mod 839 ≡ 600
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 ≡ 134 × 643-1 (mod 811) ≡ 134 × 671 (mod 811) ≡ 704 (mod 811)
x ≡ 613 × 534-1 (mod 343) ≡ 613 × 88 (mod 343) ≡ 93 (mod 343)
x ≡ 688 × 337-1 (mod 839) ≡ 688 × 600 (mod 839) ≡ 12 (mod 839)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 811 × 343 × 839 = 233387147
  2. We calculate the numbers M1 to M3
    M1=M/m1=233387147/811=287777,   M2=M/m2=233387147/343=680429,   M3=M/m3=233387147/839=278173
  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
    8112877770811010
    287777811354683101
    811683112801-1
    6831285431-16
    12843242-16-13
    4342116-1319
    421420-1319-811
    So our multiplicative inverse is 19 mod 811 ≡ 19
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3436804290343010
    6804293431983260101
    34326018301-1
    260833111-14
    831176-14-29
    116154-2933
    6511-2933-62
    515033-62343
    So our multiplicative inverse is -62 mod 343 ≡ 281
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8392781730839010
    278173839331464101
    839464137501-1
    4643751891-12
    37589419-12-9
    89194132-938
    191316-938-47
    1362138-47132
    6160-47132-839
    So our multiplicative inverse is 132 mod 839 ≡ 132
    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
    =  (704 × 287777 × 19 +
       93 × 680429 × 281 +
       12 × 278173 × 132)   mod 233387147
    = 133190423 (mod 233387147)


    So our answer is 133190423 (mod 233387147).


Verification

So we found that x ≡ 133190423
If this is correct, then the following statements (i.e. the original equations) are true:
643x (mod 811) ≡ 134 (mod 811)
534x (mod 343) ≡ 613 (mod 343)
337x (mod 839) ≡ 688 (mod 839)

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