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
251150110101-1
1501011491-12
1014923-12-5
4931612-582
3130-582-251
So our multiplicative inverse is 82 mod 251 ≡ 82
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1392060139010
206139167101
139672501-2
6751321-227
5221-227-56
212027-56139
So our multiplicative inverse is -56 mod 139 ≡ 83
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
92401092010
40192433101
923322601-2
3326171-23
26735-23-11
75123-1114
5221-1114-39
212014-3992
So our multiplicative inverse is -39 mod 92 ≡ 53
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 ≡ 182 × 150-1 (mod 251) ≡ 182 × 82 (mod 251) ≡ 115 (mod 251)
x ≡ 246 × 206-1 (mod 139) ≡ 246 × 83 (mod 139) ≡ 124 (mod 139)
x ≡ 172 × 401-1 (mod 92) ≡ 172 × 53 (mod 92) ≡ 8 (mod 92)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 251 × 139 × 92 = 3209788
  2. We calculate the numbers M1 to M3
    M1=M/m1=3209788/251=12788,   M2=M/m2=3209788/139=23092,   M3=M/m3=3209788/92=34889
  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
    251127880251010
    1278825150238101
    25123811301-1
    238131841-119
    13431-119-58
    414019-58251
    So our multiplicative inverse is -58 mod 251 ≡ 193
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    139230920139010
    2309213916618101
    1391871301-7
    1813151-78
    13523-78-23
    53128-2331
    3211-2331-54
    212031-54139
    So our multiplicative inverse is -54 mod 139 ≡ 85
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9234889092010
    348899237921101
    92214801-4
    218251-49
    8513-49-13
    53129-1322
    3211-1322-35
    212022-3592
    So our multiplicative inverse is -35 mod 92 ≡ 57
    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 × 12788 × 193 +
       124 × 23092 × 85 +
       8 × 34889 × 57)   mod 3209788
    = 674552 (mod 3209788)


    So our answer is 674552 (mod 3209788).


Verification

So we found that x ≡ 674552
If this is correct, then the following statements (i.e. the original equations) are true:
150x (mod 251) ≡ 182 (mod 251)
206x (mod 139) ≡ 246 (mod 139)
401x (mod 92) ≡ 172 (mod 92)

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