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
99452099010
45299456101
995614301-1
56431131-12
431334-12-7
134312-723
4140-723-99
So our multiplicative inverse is 23 mod 99 ≡ 23
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
34728216501-1
282654221-15
6522221-15-11
2221115-1116
211210-1116-347
So our multiplicative inverse is 16 mod 347 ≡ 16
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
857309223901-2
3092391701-23
23970329-23-11
70292123-1125
291225-1125-61
1252225-61147
5221-61147-355
2120147-355857
So our multiplicative inverse is -355 mod 857 ≡ 502
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 ≡ 687 × 452-1 (mod 99) ≡ 687 × 23 (mod 99) ≡ 60 (mod 99)
x ≡ 969 × 282-1 (mod 347) ≡ 969 × 16 (mod 347) ≡ 236 (mod 347)
x ≡ 983 × 309-1 (mod 857) ≡ 983 × 502 (mod 857) ≡ 691 (mod 857)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 99 × 347 × 857 = 29440521
  2. We calculate the numbers M1 to M3
    M1=M/m1=29440521/99=297379,   M2=M/m2=29440521/347=84843,   M3=M/m3=29440521/857=34353
  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
    99297379099010
    29737999300382101
    998211701-1
    82174141-15
    171413-15-6
    143425-629
    3211-629-35
    212029-3599
    So our multiplicative inverse is -35 mod 99 ≡ 64
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    347848430347010
    84843347244175101
    347175117201-1
    175172131-12
    1723571-12-115
    31302-115347
    So our multiplicative inverse is -115 mod 347 ≡ 232
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    857343530857010
    343538574073101
    85773115401-11
    73541191-1112
    5419216-1112-35
    19161312-3547
    16351-3547-270
    313047-270857
    So our multiplicative inverse is -270 mod 857 ≡ 587
    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
    =  (60 × 297379 × 64 +
       236 × 84843 × 232 +
       691 × 34353 × 587)   mod 29440521
    = 25711548 (mod 29440521)


    So our answer is 25711548 (mod 29440521).


Verification

So we found that x ≡ 25711548
If this is correct, then the following statements (i.e. the original equations) are true:
452x (mod 99) ≡ 687 (mod 99)
282x (mod 347) ≡ 969 (mod 347)
309x (mod 857) ≡ 983 (mod 857)

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