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
4639710463010
971463245101
46345101301-10
4513361-1031
13621-1031-72
616031-72463
So our multiplicative inverse is -72 mod 463 ≡ 391
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
289164112501-1
1641251391-12
1253938-12-7
398472-730
8711-730-37
717030-37289
So our multiplicative inverse is -37 mod 289 ≡ 252
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2396730239010
6732392195101
23919514401-1
195444191-15
441926-15-11
196315-1138
6160-1138-239
So our multiplicative inverse is 38 mod 239 ≡ 38
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 ≡ 891 × 971-1 (mod 463) ≡ 891 × 391 (mod 463) ≡ 205 (mod 463)
x ≡ 969 × 164-1 (mod 289) ≡ 969 × 252 (mod 289) ≡ 272 (mod 289)
x ≡ 797 × 673-1 (mod 239) ≡ 797 × 38 (mod 239) ≡ 172 (mod 239)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 463 × 289 × 239 = 31979873
  2. We calculate the numbers M1 to M3
    M1=M/m1=31979873/463=69071,   M2=M/m2=31979873/289=110657,   M3=M/m3=31979873/239=133807
  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
    463690710463010
    6907146314984101
    4638454301-5
    84431411-56
    434112-56-11
    4122016-11226
    2120-11226-463
    So our multiplicative inverse is 226 mod 463 ≡ 226
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2891106570289010
    110657289382259101
    28925913001-1
    259308191-19
    3019111-19-10
    1911189-1019
    11813-1019-29
    832219-2977
    3211-2977-106
    212077-106289
    So our multiplicative inverse is -106 mod 289 ≡ 183
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2391338070239010
    133807239559206101
    23920613301-1
    20633681-17
    33841-17-29
    81807-29239
    So our multiplicative inverse is -29 mod 239 ≡ 210
    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
    =  (205 × 69071 × 226 +
       272 × 110657 × 183 +
       172 × 133807 × 210)   mod 31979873
    = 13744823 (mod 31979873)


    So our answer is 13744823 (mod 31979873).


Verification

So we found that x ≡ 13744823
If this is correct, then the following statements (i.e. the original equations) are true:
971x (mod 463) ≡ 891 (mod 463)
164x (mod 289) ≡ 969 (mod 289)
673x (mod 239) ≡ 797 (mod 239)

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