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
1279950127010
9951277106101
12710612101-1
10621511-16
211210-16-127
So our multiplicative inverse is 6 mod 127 ≡ 6
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6539510653010
9516531298101
65329825701-2
298575131-211
571345-211-46
1352311-46103
5312-46103-149
3211103-149252
2120-149252-653
So our multiplicative inverse is 252 mod 653 ≡ 252
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4216560421010
6564211235101
421235118601-1
2351861491-12
18649339-12-7
49391102-79
391039-79-34
109119-3443
9190-3443-421
So our multiplicative inverse is 43 mod 421 ≡ 43
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 ≡ 675 × 995-1 (mod 127) ≡ 675 × 6 (mod 127) ≡ 113 (mod 127)
x ≡ 250 × 951-1 (mod 653) ≡ 250 × 252 (mod 653) ≡ 312 (mod 653)
x ≡ 833 × 656-1 (mod 421) ≡ 833 × 43 (mod 421) ≡ 34 (mod 421)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 127 × 653 × 421 = 34913951
  2. We calculate the numbers M1 to M3
    M1=M/m1=34913951/127=274913,   M2=M/m2=34913951/653=53467,   M3=M/m3=34913951/421=82931
  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
    1272749130127010
    274913127216485101
    1278514201-1
    8542211-13
    421420-13-127
    So our multiplicative inverse is 3 mod 127 ≡ 3
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    653534670653010
    5346765381574101
    65357417901-1
    574797211-18
    7921316-18-25
    2116158-2533
    16531-2533-124
    515033-124653
    So our multiplicative inverse is -124 mod 653 ≡ 529
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    421829310421010
    82931421196415101
    4214151601-1
    41566911-170
    6160-170-421
    So our multiplicative inverse is 70 mod 421 ≡ 70
    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
    =  (113 × 274913 × 3 +
       312 × 53467 × 529 +
       34 × 82931 × 70)   mod 34913951
    = 2651492 (mod 34913951)


    So our answer is 2651492 (mod 34913951).


Verification

So we found that x ≡ 2651492
If this is correct, then the following statements (i.e. the original equations) are true:
995x (mod 127) ≡ 675 (mod 127)
951x (mod 653) ≡ 250 (mod 653)
656x (mod 421) ≡ 833 (mod 421)

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