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
612347126501-1
3472651821-12
26582319-12-7
8219462-730
19631-730-97
616030-97612
So our multiplicative inverse is -97 mod 612 ≡ 515
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
89384015301-1
8405315451-116
534518-116-17
4585516-17101
8513-17101-118
5312101-118219
3211-118219-337
2120219-337893
So our multiplicative inverse is -337 mod 893 ≡ 556
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
959801115801-1
8011585111-16
15811144-16-85
114236-85176
4311-85176-261
3130176-261959
So our multiplicative inverse is -261 mod 959 ≡ 698
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 ≡ 576 × 347-1 (mod 612) ≡ 576 × 515 (mod 612) ≡ 432 (mod 612)
x ≡ 738 × 840-1 (mod 893) ≡ 738 × 556 (mod 893) ≡ 441 (mod 893)
x ≡ 917 × 801-1 (mod 959) ≡ 917 × 698 (mod 959) ≡ 413 (mod 959)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 612 × 893 × 959 = 524108844
  2. We calculate the numbers M1 to M3
    M1=M/m1=524108844/612=856387,   M2=M/m2=524108844/893=586908,   M3=M/m3=524108844/959=546516
  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
    6128563870612010
    8563876121399199101
    61219931501-3
    199151341-340
    15433-340-123
    431140-123163
    3130-123163-612
    So our multiplicative inverse is 163 mod 612 ≡ 163
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8935869080893010
    586908893657207101
    89320746501-4
    207653121-413
    651255-413-69
    1252213-69151
    5221-69151-371
    2120151-371893
    So our multiplicative inverse is -371 mod 893 ≡ 522
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9595465160959010
    546516959569845101
    959845111401-1
    8451147471-18
    11447220-18-17
    4720278-1742
    20726-1742-101
    761142-101143
    6160-101143-959
    So our multiplicative inverse is 143 mod 959 ≡ 143
    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
    =  (432 × 856387 × 163 +
       441 × 586908 × 522 +
       413 × 546516 × 143)   mod 524108844
    = 224192556 (mod 524108844)


    So our answer is 224192556 (mod 524108844).


Verification

So we found that x ≡ 224192556
If this is correct, then the following statements (i.e. the original equations) are true:
347x (mod 612) ≡ 576 (mod 612)
840x (mod 893) ≡ 738 (mod 893)
801x (mod 959) ≡ 917 (mod 959)

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