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
40115628901-2
156891671-23
8967122-23-5
6722313-518
221220-518-401
So our multiplicative inverse is 18 mod 401 ≡ 18
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5819900581010
9905811409101
581409117201-1
4091722651-13
17265242-13-7
65421233-710
4223119-710-17
23191410-1727
19443-1727-125
431127-125152
3130-125152-581
So our multiplicative inverse is 152 mod 581 ≡ 152
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2748790274010
879274357101
2745744601-4
57461111-45
461142-45-24
112515-24125
2120-24125-274
So our multiplicative inverse is 125 mod 274 ≡ 125
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 ≡ 56 × 156-1 (mod 401) ≡ 56 × 18 (mod 401) ≡ 206 (mod 401)
x ≡ 852 × 990-1 (mod 581) ≡ 852 × 152 (mod 581) ≡ 522 (mod 581)
x ≡ 850 × 879-1 (mod 274) ≡ 850 × 125 (mod 274) ≡ 212 (mod 274)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 401 × 581 × 274 = 63836794
  2. We calculate the numbers M1 to M3
    M1=M/m1=63836794/401=159194,   M2=M/m2=63836794/581=109874,   M3=M/m3=63836794/274=232981
  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
    4011591940401010
    159194401396398101
    4013981301-1
    398313221-1133
    3211-1133-134
    2120133-134401
    So our multiplicative inverse is -134 mod 401 ≡ 267
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5811098740581010
    10987458118965101
    5816586101-8
    6561141-89
    614151-89-143
    41409-143581
    So our multiplicative inverse is -143 mod 581 ≡ 438
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2742329810274010
    23298127485081101
    2748133101-3
    81312191-37
    3119112-37-10
    1912177-1017
    12715-1017-27
    751217-2744
    5221-2744-115
    212044-115274
    So our multiplicative inverse is -115 mod 274 ≡ 159
    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
    =  (206 × 159194 × 267 +
       522 × 109874 × 438 +
       212 × 232981 × 159)   mod 63836794
    = 45037318 (mod 63836794)


    So our answer is 45037318 (mod 63836794).


Verification

So we found that x ≡ 45037318
If this is correct, then the following statements (i.e. the original equations) are true:
156x (mod 401) ≡ 56 (mod 401)
990x (mod 581) ≡ 852 (mod 581)
879x (mod 274) ≡ 850 (mod 274)

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