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
278397501-7
395741-750
5411-750-57
414050-57278
So our multiplicative inverse is -57 mod 278 ≡ 221
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5178400517010
8405171323101
517323119401-1
32319411291-12
194129165-12-3
129651642-35
656411-35-8
6416405-8517
So our multiplicative inverse is -8 mod 517 ≡ 509
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2898140289010
8142892236101
28923615301-1
236534241-15
532425-15-11
245445-1149
5411-1149-60
414049-60289
So our multiplicative inverse is -60 mod 289 ≡ 229
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 ≡ 830 × 39-1 (mod 278) ≡ 830 × 221 (mod 278) ≡ 228 (mod 278)
x ≡ 9 × 840-1 (mod 517) ≡ 9 × 509 (mod 517) ≡ 445 (mod 517)
x ≡ 520 × 814-1 (mod 289) ≡ 520 × 229 (mod 289) ≡ 12 (mod 289)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 278 × 517 × 289 = 41536814
  2. We calculate the numbers M1 to M3
    M1=M/m1=41536814/278=149413,   M2=M/m2=41536814/517=80342,   M3=M/m3=41536814/289=143726
  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
    2781494130278010
    149413278537127101
    27812722401-2
    12724571-211
    24733-211-35
    732111-3581
    3130-3581-278
    So our multiplicative inverse is 81 mod 278 ≡ 81
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    517803420517010
    80342517155207101
    517207210301-2
    207103211-25
    10311030-25-517
    So our multiplicative inverse is 5 mod 517 ≡ 5
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2891437260289010
    14372628949793101
    2899331001-3
    9310931-328
    10331-328-87
    313028-87289
    So our multiplicative inverse is -87 mod 289 ≡ 202
    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
    =  (228 × 149413 × 81 +
       445 × 80342 × 5 +
       12 × 143726 × 202)   mod 41536814
    = 5103752 (mod 41536814)


    So our answer is 5103752 (mod 41536814).


Verification

So we found that x ≡ 5103752
If this is correct, then the following statements (i.e. the original equations) are true:
39x (mod 278) ≡ 830 (mod 278)
840x (mod 517) ≡ 9 (mod 517)
814x (mod 289) ≡ 520 (mod 289)

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