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
5479700547010
9705471423101
547423112401-1
4231243511-14
12451222-14-9
5122274-922
22731-922-75
717022-75547
So our multiplicative inverse is -75 mod 547 ≡ 472
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
46937619301-1
37693441-15
934231-15-116
41405-116469
So our multiplicative inverse is -116 mod 469 ≡ 353
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
643386125701-1
38625711291-12
2571291128-12-3
129128112-35
12811280-35-643
So our multiplicative inverse is 5 mod 643 ≡ 5
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 ≡ 154 × 970-1 (mod 547) ≡ 154 × 472 (mod 547) ≡ 484 (mod 547)
x ≡ 703 × 376-1 (mod 469) ≡ 703 × 353 (mod 469) ≡ 58 (mod 469)
x ≡ 819 × 386-1 (mod 643) ≡ 819 × 5 (mod 643) ≡ 237 (mod 643)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 547 × 469 × 643 = 164957149
  2. We calculate the numbers M1 to M3
    M1=M/m1=164957149/547=301567,   M2=M/m2=164957149/469=351721,   M3=M/m3=164957149/643=256543
  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
    5473015670547010
    301567547551170101
    54717033701-3
    170374221-313
    3722115-313-16
    22151713-1629
    15721-1629-74
    717029-74547
    So our multiplicative inverse is -74 mod 547 ≡ 473
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4693517210469010
    351721469749440101
    46944012901-1
    440291551-116
    29554-116-81
    541116-8197
    4140-8197-469
    So our multiplicative inverse is 97 mod 469 ≡ 97
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6432565430643010
    256543643398629101
    64362911401-1
    6291444131-145
    141311-145-46
    13113045-46643
    So our multiplicative inverse is -46 mod 643 ≡ 597
    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
    =  (484 × 301567 × 473 +
       58 × 351721 × 97 +
       237 × 256543 × 597)   mod 164957149
    = 92984467 (mod 164957149)


    So our answer is 92984467 (mod 164957149).


Verification

So we found that x ≡ 92984467
If this is correct, then the following statements (i.e. the original equations) are true:
970x (mod 547) ≡ 154 (mod 547)
376x (mod 469) ≡ 703 (mod 469)
386x (mod 643) ≡ 819 (mod 643)

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