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
3684890368010
4893681121101
3681213501-3
12152411-373
5150-373-368
So our multiplicative inverse is 73 mod 368 ≡ 73
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1574780157010
47815737101
157722301-22
73211-2245
3130-2245-157
So our multiplicative inverse is 45 mod 157 ≡ 45
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2734000273010
4002731127101
27312721901-2
127196131-213
191316-213-15
1362113-1543
6160-1543-273
So our multiplicative inverse is 43 mod 273 ≡ 43
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 ≡ 146 × 489-1 (mod 368) ≡ 146 × 73 (mod 368) ≡ 354 (mod 368)
x ≡ 238 × 478-1 (mod 157) ≡ 238 × 45 (mod 157) ≡ 34 (mod 157)
x ≡ 668 × 400-1 (mod 273) ≡ 668 × 43 (mod 273) ≡ 59 (mod 273)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 368 × 157 × 273 = 15772848
  2. We calculate the numbers M1 to M3
    M1=M/m1=15772848/368=42861,   M2=M/m2=15772848/157=100464,   M3=M/m3=15772848/273=57776
  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
    368428610368010
    42861368116173101
    36817322201-2
    173227191-215
    221913-215-17
    1936115-17117
    3130-17117-368
    So our multiplicative inverse is 117 mod 368 ≡ 117
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1571004640157010
    100464157639141101
    15714111601-1
    141168131-19
    161313-19-10
    133419-1049
    3130-1049-157
    So our multiplicative inverse is 49 mod 157 ≡ 49
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    273577760273010
    57776273211173101
    273173110001-1
    1731001731-12
    10073127-12-3
    73272192-38
    271918-38-11
    198238-1130
    8322-1130-71
    321130-71101
    2120-71101-273
    So our multiplicative inverse is 101 mod 273 ≡ 101
    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
    =  (354 × 42861 × 117 +
       34 × 100464 × 49 +
       59 × 57776 × 101)   mod 15772848
    = 15586994 (mod 15772848)


    So our answer is 15586994 (mod 15772848).


Verification

So we found that x ≡ 15586994
If this is correct, then the following statements (i.e. the original equations) are true:
489x (mod 368) ≡ 146 (mod 368)
478x (mod 157) ≡ 238 (mod 157)
400x (mod 273) ≡ 668 (mod 273)

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