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
3198490319010
8493192211101
319211110801-1
21110811031-12
10810315-12-3
10352032-362
5312-362-65
321162-65127
2120-65127-319
So our multiplicative inverse is 127 mod 319 ≡ 127
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2115290211010
5292112107101
211107110401-1
107104131-12
1043342-12-69
32112-6971
2120-6971-211
So our multiplicative inverse is 71 mod 211 ≡ 71
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2254030225010
4032251178101
22517814701-1
178473371-14
4737110-14-5
3710374-519
10713-519-24
732119-2467
3130-2467-225
So our multiplicative inverse is 67 mod 225 ≡ 67
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 ≡ 21 × 849-1 (mod 319) ≡ 21 × 127 (mod 319) ≡ 115 (mod 319)
x ≡ 472 × 529-1 (mod 211) ≡ 472 × 71 (mod 211) ≡ 174 (mod 211)
x ≡ 257 × 403-1 (mod 225) ≡ 257 × 67 (mod 225) ≡ 119 (mod 225)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 319 × 211 × 225 = 15144525
  2. We calculate the numbers M1 to M3
    M1=M/m1=15144525/319=47475,   M2=M/m2=15144525/211=71775,   M3=M/m3=15144525/225=67309
  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
    319474750319010
    47475319148263101
    31926315601-1
    263564391-15
    5639117-15-6
    3917255-617
    17532-617-57
    522117-57131
    2120-57131-319
    So our multiplicative inverse is 131 mod 319 ≡ 131
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    211717750211010
    7177521134035101
    211356101-6
    3513501-6211
    So our multiplicative inverse is -6 mod 211 ≡ 205
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    225673090225010
    6730922529934101
    2253462101-6
    34211131-67
    211318-67-13
    138157-1320
    8513-1320-33
    531220-3353
    3211-3353-86
    212053-86225
    So our multiplicative inverse is -86 mod 225 ≡ 139
    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
    =  (115 × 47475 × 131 +
       174 × 71775 × 205 +
       119 × 67309 × 139)   mod 15144525
    = 12015569 (mod 15144525)


    So our answer is 12015569 (mod 15144525).


Verification

So we found that x ≡ 12015569
If this is correct, then the following statements (i.e. the original equations) are true:
849x (mod 319) ≡ 21 (mod 319)
529x (mod 211) ≡ 472 (mod 211)
403x (mod 225) ≡ 257 (mod 225)

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