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
853539131401-1
53931412251-12
314225189-12-3
225892472-38
8947142-38-11
4742158-1119
42582-1119-163
522119-163345
2120-163345-853
So our multiplicative inverse is 345 mod 853 ≡ 345
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
37848037010
848372234101
37341301-1
3431111-112
3130-112-37
So our multiplicative inverse is 12 mod 37 ≡ 12
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5051631901-31
169171-3132
9712-3132-63
723132-63221
2120-63221-505
So our multiplicative inverse is 221 mod 505 ≡ 221
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 ≡ 938 × 539-1 (mod 853) ≡ 938 × 345 (mod 853) ≡ 323 (mod 853)
x ≡ 826 × 848-1 (mod 37) ≡ 826 × 12 (mod 37) ≡ 33 (mod 37)
x ≡ 633 × 16-1 (mod 505) ≡ 633 × 221 (mod 505) ≡ 8 (mod 505)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 853 × 37 × 505 = 15938305
  2. We calculate the numbers M1 to M3
    M1=M/m1=15938305/853=18685,   M2=M/m2=15938305/37=430765,   M3=M/m3=15938305/505=31561
  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
    853186850853010
    1868585321772101
    85377218101-1
    772819431-110
    8143138-110-11
    43381510-1121
    38573-1121-158
    531221-158179
    3211-158179-337
    2120179-337853
    So our multiplicative inverse is -337 mod 853 ≡ 516
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    37430765037010
    430765371164211101
    37113401-3
    114231-37
    4311-37-10
    31307-1037
    So our multiplicative inverse is -10 mod 37 ≡ 27
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    505315610505010
    3156150562251101
    5052512301-2
    25138321-2167
    3211-2167-169
    2120167-169505
    So our multiplicative inverse is -169 mod 505 ≡ 336
    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
    =  (323 × 18685 × 516 +
       33 × 430765 × 27 +
       8 × 31561 × 336)   mod 15938305
    = 12658843 (mod 15938305)


    So our answer is 12658843 (mod 15938305).


Verification

So we found that x ≡ 12658843
If this is correct, then the following statements (i.e. the original equations) are true:
539x (mod 853) ≡ 938 (mod 853)
848x (mod 37) ≡ 826 (mod 37)
16x (mod 505) ≡ 633 (mod 505)

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