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
4639540463010
954463228101
46328161501-16
28151131-1617
151312-1617-33
1326117-33215
2120-33215-463
So our multiplicative inverse is 215 mod 463 ≡ 215
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5435440543010
54454311101
5431543001-543
So our multiplicative inverse is 1 mod 543 ≡ 1
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8219260821010
9268211105101
82110578601-7
105861191-78
8619410-78-39
1910198-3947
10911-3947-86
919047-86821
So our multiplicative inverse is -86 mod 821 ≡ 735
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 ≡ 971 × 954-1 (mod 463) ≡ 971 × 215 (mod 463) ≡ 415 (mod 463)
x ≡ 916 × 544-1 (mod 543) ≡ 916 × 1 (mod 543) ≡ 373 (mod 543)
x ≡ 873 × 926-1 (mod 821) ≡ 873 × 735 (mod 821) ≡ 454 (mod 821)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 463 × 543 × 821 = 206406789
  2. We calculate the numbers M1 to M3
    M1=M/m1=206406789/463=445803,   M2=M/m2=206406789/543=380123,   M3=M/m3=206406789/821=251409
  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
    4634458030463010
    445803463962397101
    46339716601-1
    39766611-17
    661660-17-463
    So our multiplicative inverse is 7 mod 463 ≡ 7
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5433801230543010
    38012354370023101
    54323231401-23
    2314191-2324
    14915-2324-47
    951424-4771
    5411-4771-118
    414071-118543
    So our multiplicative inverse is -118 mod 543 ≡ 425
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8212514090821010
    251409821306183101
    82118348901-4
    18389251-49
    895174-49-157
    54119-157166
    4140-157166-821
    So our multiplicative inverse is 166 mod 821 ≡ 166
    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
    =  (415 × 445803 × 7 +
       373 × 380123 × 425 +
       454 × 251409 × 166)   mod 206406789
    = 2596456 (mod 206406789)


    So our answer is 2596456 (mod 206406789).


Verification

So we found that x ≡ 2596456
If this is correct, then the following statements (i.e. the original equations) are true:
954x (mod 463) ≡ 971 (mod 463)
544x (mod 543) ≡ 916 (mod 543)
926x (mod 821) ≡ 873 (mod 821)

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