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
3236310323010
6313231308101
32330811501-1
308152081-121
15817-121-22
871121-2243
7170-2243-323
So our multiplicative inverse is 43 mod 323 ≡ 43
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
85133252601-25
3326171-2526
26735-2526-103
751226-103129
5221-103129-361
2120129-361851
So our multiplicative inverse is -361 mod 851 ≡ 490
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
701505119601-1
50519621131-13
196113183-13-4
113831303-47
8330223-47-18
3023177-1825
23732-1825-93
723125-93304
2120-93304-701
So our multiplicative inverse is 304 mod 701 ≡ 304
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 ≡ 165 × 631-1 (mod 323) ≡ 165 × 43 (mod 323) ≡ 312 (mod 323)
x ≡ 273 × 33-1 (mod 851) ≡ 273 × 490 (mod 851) ≡ 163 (mod 851)
x ≡ 111 × 505-1 (mod 701) ≡ 111 × 304 (mod 701) ≡ 96 (mod 701)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 323 × 851 × 701 = 192685973
  2. We calculate the numbers M1 to M3
    M1=M/m1=192685973/323=596551,   M2=M/m2=192685973/851=226423,   M3=M/m3=192685973/701=274873
  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
    3235965510323010
    5965513231846293101
    32329313001-1
    293309231-110
    302317-110-11
    2373210-1143
    7231-1143-140
    212043-140323
    So our multiplicative inverse is -140 mod 323 ≡ 183
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8512264230851010
    22642385126657101
    85157145301-14
    5753141-1415
    534131-1415-209
    414015-209851
    So our multiplicative inverse is -209 mod 851 ≡ 642
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7012748730701010
    27487370139281101
    7018185301-8
    81531281-89
    5328125-89-17
    2825139-1726
    25381-1726-225
    313026-225701
    So our multiplicative inverse is -225 mod 701 ≡ 476
    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
    =  (312 × 596551 × 183 +
       163 × 226423 × 642 +
       96 × 274873 × 476)   mod 192685973
    = 177839590 (mod 192685973)


    So our answer is 177839590 (mod 192685973).


Verification

So we found that x ≡ 177839590
If this is correct, then the following statements (i.e. the original equations) are true:
631x (mod 323) ≡ 165 (mod 323)
33x (mod 851) ≡ 273 (mod 851)
505x (mod 701) ≡ 111 (mod 701)

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