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
17169017010
16917916101
17161101-1
1611601-117
So our multiplicative inverse is -1 mod 17 ≡ 16
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4339030433010
903433237101
43337112601-11
37261111-1112
261124-1112-35
1142312-3582
4311-3582-117
313082-117433
So our multiplicative inverse is -117 mod 433 ≡ 316
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2277050227010
705227324101
2272491101-9
2411221-919
11251-919-104
212019-104227
So our multiplicative inverse is -104 mod 227 ≡ 123
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 ≡ 929 × 169-1 (mod 17) ≡ 929 × 16 (mod 17) ≡ 6 (mod 17)
x ≡ 671 × 903-1 (mod 433) ≡ 671 × 316 (mod 433) ≡ 299 (mod 433)
x ≡ 699 × 705-1 (mod 227) ≡ 699 × 123 (mod 227) ≡ 171 (mod 227)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 17 × 433 × 227 = 1670947
  2. We calculate the numbers M1 to M3
    M1=M/m1=1670947/17=98291,   M2=M/m2=1670947/433=3859,   M3=M/m3=1670947/227=7361
  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
    1798291017010
    9829117578114101
    17141301-1
    143421-15
    3211-15-6
    21205-617
    So our multiplicative inverse is -6 mod 17 ≡ 11
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    43338590433010
    38594338395101
    43339513801-1
    3953810151-111
    381528-111-23
    1581711-2334
    8711-2334-57
    717034-57433
    So our multiplicative inverse is -57 mod 433 ≡ 376
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    22773610227010
    73612273297101
    2279723301-2
    97332311-25
    333112-25-7
    3121515-7110
    2120-7110-227
    So our multiplicative inverse is 110 mod 227 ≡ 110
    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
    =  (6 × 98291 × 11 +
       299 × 3859 × 376 +
       171 × 7361 × 110)   mod 1670947
    = 644170 (mod 1670947)


    So our answer is 644170 (mod 1670947).


Verification

So we found that x ≡ 644170
If this is correct, then the following statements (i.e. the original equations) are true:
169x (mod 17) ≡ 929 (mod 17)
903x (mod 433) ≡ 671 (mod 433)
705x (mod 227) ≡ 699 (mod 227)

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