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
85738428901-2
384894281-29
892835-29-29
285539-29154
5312-29154-183
3211154-183337
2120-183337-857
So our multiplicative inverse is 337 mod 857 ≡ 337
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
45121422301-2
21423971-219
23732-219-59
723119-59196
2120-59196-451
So our multiplicative inverse is 196 mod 451 ≡ 196
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
97290097010
29097296101
97961101-1
9619601-197
So our multiplicative inverse is -1 mod 97 ≡ 96
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 ≡ 383 × 384-1 (mod 857) ≡ 383 × 337 (mod 857) ≡ 521 (mod 857)
x ≡ 27 × 214-1 (mod 451) ≡ 27 × 196 (mod 451) ≡ 331 (mod 451)
x ≡ 106 × 290-1 (mod 97) ≡ 106 × 96 (mod 97) ≡ 88 (mod 97)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 857 × 451 × 97 = 37491179
  2. We calculate the numbers M1 to M3
    M1=M/m1=37491179/857=43747,   M2=M/m2=37491179/451=83129,   M3=M/m3=37491179/97=386507
  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
    857437470857010
    437478575140101
    85740211701-21
    4017261-2143
    17625-2143-107
    651143-107150
    5150-107150-857
    So our multiplicative inverse is 150 mod 857 ≡ 150
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    451831290451010
    83129451184145101
    45114531601-3
    14516911-328
    161160-328-451
    So our multiplicative inverse is 28 mod 451 ≡ 28
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    97386507097010
    38650797398459101
    975913801-1
    59381211-12
    3821117-12-3
    2117142-35
    17441-35-23
    41405-2397
    So our multiplicative inverse is -23 mod 97 ≡ 74
    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
    =  (521 × 43747 × 150 +
       331 × 83129 × 28 +
       88 × 386507 × 74)   mod 37491179
    = 32771344 (mod 37491179)


    So our answer is 32771344 (mod 37491179).


Verification

So we found that x ≡ 32771344
If this is correct, then the following statements (i.e. the original equations) are true:
384x (mod 857) ≡ 383 (mod 857)
214x (mod 451) ≡ 27 (mod 451)
290x (mod 97) ≡ 106 (mod 97)

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