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
76635924801-2
359487231-215
482322-215-32
23211115-32367
2120-32367-766
So our multiplicative inverse is 367 mod 766 ≡ 367
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2413563101-6
3531141-67
31473-67-55
43117-5562
3130-5562-241
So our multiplicative inverse is 62 mod 241 ≡ 62
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
40732817901-1
328794121-15
791267-15-31
127155-3136
7512-3136-67
522136-67170
2120-67170-407
So our multiplicative inverse is 170 mod 407 ≡ 170
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 ≡ 529 × 359-1 (mod 766) ≡ 529 × 367 (mod 766) ≡ 345 (mod 766)
x ≡ 709 × 35-1 (mod 241) ≡ 709 × 62 (mod 241) ≡ 96 (mod 241)
x ≡ 68 × 328-1 (mod 407) ≡ 68 × 170 (mod 407) ≡ 164 (mod 407)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 766 × 241 × 407 = 75134642
  2. We calculate the numbers M1 to M3
    M1=M/m1=75134642/766=98087,   M2=M/m2=75134642/241=311762,   M3=M/m3=75134642/407=184606
  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
    766980870766010
    9808776612839101
    76639192501-19
    39251141-1920
    2514111-1920-39
    14111320-3959
    11332-3959-216
    321159-216275
    2120-216275-766
    So our multiplicative inverse is 275 mod 766 ≡ 275
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2413117620241010
    3117622411293149101
    24114919201-1
    149921571-12
    9257135-12-3
    57351222-35
    3522113-35-8
    2213195-813
    13914-813-21
    942113-2155
    4140-2155-241
    So our multiplicative inverse is 55 mod 241 ≡ 55
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4071846060407010
    184606407453235101
    407235117201-1
    2351721631-12
    17263246-12-5
    63461172-57
    4617212-57-19
    1712157-1926
    12522-1926-71
    522126-71168
    2120-71168-407
    So our multiplicative inverse is 168 mod 407 ≡ 168
    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
    =  (345 × 98087 × 275 +
       96 × 311762 × 55 +
       164 × 184606 × 168)   mod 75134642
    = 34693251 (mod 75134642)


    So our answer is 34693251 (mod 75134642).


Verification

So we found that x ≡ 34693251
If this is correct, then the following statements (i.e. the original equations) are true:
359x (mod 766) ≡ 529 (mod 766)
35x (mod 241) ≡ 709 (mod 241)
328x (mod 407) ≡ 68 (mod 407)

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