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
3537300353010
730353224101
35324141701-14
2417171-1415
17723-1415-44
732115-44103
3130-44103-353
So our multiplicative inverse is 103 mod 353 ≡ 103
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2594150259010
4152591156101
259156110301-1
1561031531-12
10353150-12-3
5350132-35
503162-35-83
32115-8388
2120-8388-259
So our multiplicative inverse is 88 mod 259 ≡ 88
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4178120417010
8124171395101
41739512201-1
3952217211-118
222111-118-19
21121018-19417
So our multiplicative inverse is -19 mod 417 ≡ 398
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 ≡ 93 × 730-1 (mod 353) ≡ 93 × 103 (mod 353) ≡ 48 (mod 353)
x ≡ 179 × 415-1 (mod 259) ≡ 179 × 88 (mod 259) ≡ 212 (mod 259)
x ≡ 419 × 812-1 (mod 417) ≡ 419 × 398 (mod 417) ≡ 379 (mod 417)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 353 × 259 × 417 = 38125059
  2. We calculate the numbers M1 to M3
    M1=M/m1=38125059/353=108003,   M2=M/m2=38125059/259=147201,   M3=M/m3=38125059/417=91427
  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
    3531080030353010
    108003353305338101
    35333811501-1
    338152281-123
    15817-123-24
    871123-2447
    7170-2447-353
    So our multiplicative inverse is 47 mod 353 ≡ 47
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2591472010259010
    14720125956889101
    2598928101-2
    8981181-23
    818101-23-32
    81803-32259
    So our multiplicative inverse is -32 mod 259 ≡ 227
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    417914270417010
    91427417219104101
    4171044101-4
    104110401-4417
    So our multiplicative inverse is -4 mod 417 ≡ 413
    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
    =  (48 × 108003 × 47 +
       212 × 147201 × 227 +
       379 × 91427 × 413)   mod 38125059
    = 21441268 (mod 38125059)


    So our answer is 21441268 (mod 38125059).


Verification

So we found that x ≡ 21441268
If this is correct, then the following statements (i.e. the original equations) are true:
730x (mod 353) ≡ 93 (mod 353)
415x (mod 259) ≡ 179 (mod 259)
812x (mod 417) ≡ 419 (mod 417)

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