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
1938400193010
840193468101
1936825701-2
68571111-23
571152-23-17
112513-1788
2120-1788-193
So our multiplicative inverse is 88 mod 193 ≡ 88
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
12310611701-1
10617641-17
17441-17-29
41407-29123
So our multiplicative inverse is -29 mod 123 ≡ 94
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7697750769010
77576916101
7696128101-128
61601-128769
So our multiplicative inverse is -128 mod 769 ≡ 641
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 ≡ 259 × 840-1 (mod 193) ≡ 259 × 88 (mod 193) ≡ 18 (mod 193)
x ≡ 235 × 106-1 (mod 123) ≡ 235 × 94 (mod 123) ≡ 73 (mod 123)
x ≡ 862 × 775-1 (mod 769) ≡ 862 × 641 (mod 769) ≡ 400 (mod 769)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 193 × 123 × 769 = 18255291
  2. We calculate the numbers M1 to M3
    M1=M/m1=18255291/193=94587,   M2=M/m2=18255291/123=148417,   M3=M/m3=18255291/769=23739
  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
    193945870193010
    9458719349017101
    1931711601-11
    176251-1123
    6511-1123-34
    515023-34193
    So our multiplicative inverse is -34 mod 193 ≡ 159
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1231484170123010
    148417123120679101
    1237914401-1
    79441351-12
    443519-12-3
    359382-311
    9811-311-14
    818011-14123
    So our multiplicative inverse is -14 mod 123 ≡ 109
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    769237390769010
    2373976930669101
    769669110001-1
    6691006691-17
    10069131-17-8
    6931277-823
    31743-823-100
    732123-100223
    3130-100223-769
    So our multiplicative inverse is 223 mod 769 ≡ 223
    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
    =  (18 × 94587 × 159 +
       73 × 148417 × 109 +
       400 × 23739 × 223)   mod 18255291
    = 9399118 (mod 18255291)


    So our answer is 9399118 (mod 18255291).


Verification

So we found that x ≡ 9399118
If this is correct, then the following statements (i.e. the original equations) are true:
840x (mod 193) ≡ 259 (mod 193)
106x (mod 123) ≡ 235 (mod 123)
775x (mod 769) ≡ 862 (mod 769)

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