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
7679020767010
9027671135101
76713559201-5
135921431-56
924326-56-17
436716-17125
6160-17125-767
So our multiplicative inverse is 125 mod 767 ≡ 125
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
893248314901-3
2481491991-34
14999150-34-7
99501494-711
504911-711-18
49149011-18893
So our multiplicative inverse is -18 mod 893 ≡ 875
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
977786119101-1
7861914221-15
19122815-15-41
2215175-4146
15721-4146-133
717046-133977
So our multiplicative inverse is -133 mod 977 ≡ 844
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 ≡ 939 × 902-1 (mod 767) ≡ 939 × 125 (mod 767) ≡ 24 (mod 767)
x ≡ 179 × 248-1 (mod 893) ≡ 179 × 875 (mod 893) ≡ 350 (mod 893)
x ≡ 329 × 786-1 (mod 977) ≡ 329 × 844 (mod 977) ≡ 208 (mod 977)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 767 × 893 × 977 = 669177587
  2. We calculate the numbers M1 to M3
    M1=M/m1=669177587/767=872461,   M2=M/m2=669177587/893=749359,   M3=M/m3=669177587/977=684931
  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
    7678724610767010
    8724617671137382101
    7673822301-2
    382312711-2255
    3130-2255-767
    So our multiplicative inverse is 255 mod 767 ≡ 255
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8937493590893010
    749359893839132101
    893132610101-6
    1321011311-67
    1013138-67-27
    318377-2788
    8711-2788-115
    717088-115893
    So our multiplicative inverse is -115 mod 893 ≡ 778
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9776849310977010
    68493197770154101
    9775418501-18
    5451041-18181
    5411-18181-199
    4140181-199977
    So our multiplicative inverse is -199 mod 977 ≡ 778
    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
    =  (24 × 872461 × 255 +
       350 × 749359 × 778 +
       208 × 684931 × 778)   mod 669177587
    = 361304578 (mod 669177587)


    So our answer is 361304578 (mod 669177587).


Verification

So we found that x ≡ 361304578
If this is correct, then the following statements (i.e. the original equations) are true:
902x (mod 767) ≡ 939 (mod 767)
248x (mod 893) ≡ 179 (mod 893)
786x (mod 977) ≡ 329 (mod 977)

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