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
503401110201-1
4011023951-14
1029517-14-5
9571344-569
7413-569-74
431169-74143
3130-74143-503
So our multiplicative inverse is 143 mod 503 ≡ 143
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5171713401-3
17144231-3127
4311-3127-130
3130127-130517
So our multiplicative inverse is -130 mod 517 ≡ 387
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3796030379010
6033791224101
379224115501-1
2241551691-12
15569217-12-5
6917412-522
171170-522-379
So our multiplicative inverse is 22 mod 379 ≡ 22
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 ≡ 528 × 401-1 (mod 503) ≡ 528 × 143 (mod 503) ≡ 54 (mod 503)
x ≡ 143 × 171-1 (mod 517) ≡ 143 × 387 (mod 517) ≡ 22 (mod 517)
x ≡ 471 × 603-1 (mod 379) ≡ 471 × 22 (mod 379) ≡ 129 (mod 379)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 503 × 517 × 379 = 98559329
  2. We calculate the numbers M1 to M3
    M1=M/m1=98559329/503=195943,   M2=M/m2=98559329/517=190637,   M3=M/m3=98559329/379=260051
  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
    5031959430503010
    195943503389276101
    503276122701-1
    2762271491-12
    22749431-12-9
    49311182-911
    3118113-911-20
    18131511-2031
    13523-2031-82
    531231-82113
    3211-82113-195
    2120113-195503
    So our multiplicative inverse is -195 mod 503 ≡ 308
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5171906370517010
    190637517368381101
    517381113601-1
    38113621091-13
    136109127-13-4
    10927413-419
    271270-419-517
    So our multiplicative inverse is 19 mod 517 ≡ 19
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3792600510379010
    26005137968657101
    3795763701-6
    57371201-67
    3720117-67-13
    2017137-1320
    17352-1320-113
    321120-113133
    2120-113133-379
    So our multiplicative inverse is 133 mod 379 ≡ 133
    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
    =  (54 × 195943 × 308 +
       22 × 190637 × 19 +
       129 × 260051 × 133)   mod 98559329
    = 14118258 (mod 98559329)


    So our answer is 14118258 (mod 98559329).


Verification

So we found that x ≡ 14118258
If this is correct, then the following statements (i.e. the original equations) are true:
401x (mod 503) ≡ 528 (mod 503)
171x (mod 517) ≡ 143 (mod 517)
603x (mod 379) ≡ 471 (mod 379)

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