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
8599170859010
917859158101
85958144701-14
58471111-1415
471143-1415-74
1133215-74237
3211-74237-311
2120237-311859
So our multiplicative inverse is -311 mod 859 ≡ 548
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4491237501-37
125221-3775
5221-3775-187
212075-187449
So our multiplicative inverse is -187 mod 449 ≡ 262
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6197770619010
7776191158101
619158314501-3
1581451131-34
14513112-34-47
132614-47286
2120-47286-619
So our multiplicative inverse is 286 mod 619 ≡ 286
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 ≡ 465 × 917-1 (mod 859) ≡ 465 × 548 (mod 859) ≡ 556 (mod 859)
x ≡ 292 × 12-1 (mod 449) ≡ 292 × 262 (mod 449) ≡ 174 (mod 449)
x ≡ 915 × 777-1 (mod 619) ≡ 915 × 286 (mod 619) ≡ 472 (mod 619)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 859 × 449 × 619 = 238742729
  2. We calculate the numbers M1 to M3
    M1=M/m1=238742729/859=277931,   M2=M/m2=238742729/449=531721,   M3=M/m3=238742729/619=385691
  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
    8592779310859010
    277931859323474101
    859474138501-1
    4743851891-12
    38589429-12-9
    8929322-929
    292141-929-415
    212029-415859
    So our multiplicative inverse is -415 mod 859 ≡ 444
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4495317210449010
    5317214491184105101
    44910542901-4
    105293181-413
    2918111-413-17
    18111713-1730
    11714-1730-47
    741330-4777
    4311-4777-124
    313077-124449
    So our multiplicative inverse is -124 mod 449 ≡ 325
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6193856910619010
    38569161962354101
    61954112501-11
    5425241-1123
    25461-1123-149
    414023-149619
    So our multiplicative inverse is -149 mod 619 ≡ 470
    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
    =  (556 × 277931 × 444 +
       174 × 531721 × 325 +
       472 × 385691 × 470)   mod 238742729
    = 171028315 (mod 238742729)


    So our answer is 171028315 (mod 238742729).


Verification

So we found that x ≡ 171028315
If this is correct, then the following statements (i.e. the original equations) are true:
917x (mod 859) ≡ 465 (mod 859)
12x (mod 449) ≡ 292 (mod 449)
777x (mod 619) ≡ 915 (mod 619)

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