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
3218600321010
8603212218101
321218110301-1
2181032121-13
1031287-13-25
127153-2528
7512-2528-53
522128-53134
2120-53134-321
So our multiplicative inverse is 134 mod 321 ≡ 134
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5637520563010
7525631189101
563189218501-2
189185141-23
1854461-23-140
41403-140563
So our multiplicative inverse is -140 mod 563 ≡ 423
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6478150647010
8156471168101
647168314301-3
1681431251-34
14325518-34-23
2518174-2327
18724-2327-77
741327-77104
4311-77104-181
3130104-181647
So our multiplicative inverse is -181 mod 647 ≡ 466
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 ≡ 682 × 860-1 (mod 321) ≡ 682 × 134 (mod 321) ≡ 224 (mod 321)
x ≡ 503 × 752-1 (mod 563) ≡ 503 × 423 (mod 563) ≡ 518 (mod 563)
x ≡ 999 × 815-1 (mod 647) ≡ 999 × 466 (mod 647) ≡ 341 (mod 647)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 321 × 563 × 647 = 116927781
  2. We calculate the numbers M1 to M3
    M1=M/m1=116927781/321=364261,   M2=M/m2=116927781/563=207687,   M3=M/m3=116927781/647=180723
  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
    3213642610321010
    3642613211134247101
    32124717401-1
    247743251-14
    7425224-14-9
    2524114-913
    241240-913-321
    So our multiplicative inverse is 13 mod 321 ≡ 13
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5632076870563010
    207687563368503101
    56350316001-1
    503608231-19
    6023214-19-19
    2314199-1928
    14915-1928-47
    951428-4775
    5411-4775-122
    414075-122563
    So our multiplicative inverse is -122 mod 563 ≡ 441
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6471807230647010
    180723647279210101
    64721031701-3
    210171261-337
    17625-337-77
    651137-77114
    5150-77114-647
    So our multiplicative inverse is 114 mod 647 ≡ 114
    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
    =  (224 × 364261 × 13 +
       518 × 207687 × 441 +
       341 × 180723 × 114)   mod 116927781
    = 105988646 (mod 116927781)


    So our answer is 105988646 (mod 116927781).


Verification

So we found that x ≡ 105988646
If this is correct, then the following statements (i.e. the original equations) are true:
860x (mod 321) ≡ 682 (mod 321)
752x (mod 563) ≡ 503 (mod 563)
815x (mod 647) ≡ 999 (mod 647)

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