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
79117449501-4
174951791-45
9579116-45-9
79164155-941
161511-941-50
15115041-50791
So our multiplicative inverse is -50 mod 791 ≡ 741
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5217400521010
7405211219101
52121928301-2
219832531-25
8353130-25-7
53301235-712
302317-712-19
2373212-1969
7231-1969-226
212069-226521
So our multiplicative inverse is -226 mod 521 ≡ 295
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6832626701-26
267351-2679
7512-2679-105
522179-105289
2120-105289-683
So our multiplicative inverse is 289 mod 683 ≡ 289
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 ≡ 627 × 174-1 (mod 791) ≡ 627 × 741 (mod 791) ≡ 290 (mod 791)
x ≡ 591 × 740-1 (mod 521) ≡ 591 × 295 (mod 521) ≡ 331 (mod 521)
x ≡ 196 × 26-1 (mod 683) ≡ 196 × 289 (mod 683) ≡ 638 (mod 683)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 791 × 521 × 683 = 281471813
  2. We calculate the numbers M1 to M3
    M1=M/m1=281471813/791=355843,   M2=M/m2=281471813/521=540253,   M3=M/m3=281471813/683=412111
  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
    7913558430791010
    355843791449684101
    791684110701-1
    6841076421-17
    10742223-17-15
    42231197-1522
    231914-1522-37
    1944322-37170
    4311-37170-207
    3130170-207791
    So our multiplicative inverse is -207 mod 791 ≡ 584
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5215402530521010
    5402535211036497101
    52149712401-1
    4972420171-121
    241717-121-22
    1772321-2265
    7321-2265-152
    313065-152521
    So our multiplicative inverse is -152 mod 521 ≡ 369
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6834121110683010
    412111683603262101
    683262215901-2
    26215911031-23
    159103156-23-5
    103561473-58
    564719-58-13
    479528-1373
    9241-1373-305
    212073-305683
    So our multiplicative inverse is -305 mod 683 ≡ 378
    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
    =  (290 × 355843 × 584 +
       331 × 540253 × 369 +
       638 × 412111 × 378)   mod 281471813
    = 178946638 (mod 281471813)


    So our answer is 178946638 (mod 281471813).


Verification

So we found that x ≡ 178946638
If this is correct, then the following statements (i.e. the original equations) are true:
174x (mod 791) ≡ 627 (mod 791)
740x (mod 521) ≡ 591 (mod 521)
26x (mod 683) ≡ 196 (mod 683)

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