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
673423125001-1
42325011731-12
250173177-12-3
173772192-38
771941-38-35
1911908-35673
So our multiplicative inverse is -35 mod 673 ≡ 638
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
85376219101-1
762918341-19
9134223-19-19
34231119-1928
231121-1928-75
11111028-75853
So our multiplicative inverse is -75 mod 853 ≡ 778
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1075790107010
579107544101
1074421901-2
4419261-25
19631-25-17
61605-17107
So our multiplicative inverse is -17 mod 107 ≡ 90
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 ≡ 192 × 423-1 (mod 673) ≡ 192 × 638 (mod 673) ≡ 10 (mod 673)
x ≡ 640 × 762-1 (mod 853) ≡ 640 × 778 (mod 853) ≡ 621 (mod 853)
x ≡ 354 × 579-1 (mod 107) ≡ 354 × 90 (mod 107) ≡ 81 (mod 107)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 673 × 853 × 107 = 61425383
  2. We calculate the numbers M1 to M3
    M1=M/m1=61425383/673=91271,   M2=M/m2=61425383/853=72011,   M3=M/m3=61425383/107=574069
  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
    673912710673010
    91271673135416101
    673416125701-1
    41625711591-12
    257159198-12-3
    159981612-35
    9861137-35-8
    61371245-813
    3724113-813-21
    241311113-2134
    131112-2134-55
    1125134-55309
    2120-55309-673
    So our multiplicative inverse is 309 mod 673 ≡ 309
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    853720110853010
    7201185384359101
    853359213501-2
    3591352891-25
    13589146-25-7
    89461435-712
    464313-712-19
    43314112-19278
    3130-19278-853
    So our multiplicative inverse is 278 mod 853 ≡ 278
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1075740690107010
    574069107536514101
    107147901-7
    149151-78
    9514-78-15
    54118-1523
    4140-1523-107
    So our multiplicative inverse is 23 mod 107 ≡ 23
    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
    =  (10 × 91271 × 309 +
       621 × 72011 × 278 +
       81 × 574069 × 23)   mod 61425383
    = 24067163 (mod 61425383)


    So our answer is 24067163 (mod 61425383).


Verification

So we found that x ≡ 24067163
If this is correct, then the following statements (i.e. the original equations) are true:
423x (mod 673) ≡ 192 (mod 673)
762x (mod 853) ≡ 640 (mod 853)
579x (mod 107) ≡ 354 (mod 107)

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