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
96729837301-3
29873461-313
736121-313-159
616013-159967
So our multiplicative inverse is -159 mod 967 ≡ 808
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1582362001-6
2320131-67
20362-67-48
32117-4855
2120-4855-158
So our multiplicative inverse is 55 mod 158 ≡ 55
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
97159162701-16
5927251-1633
27552-1633-181
522133-181395
2120-181395-971
So our multiplicative inverse is 395 mod 971 ≡ 395
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 ≡ 978 × 298-1 (mod 967) ≡ 978 × 808 (mod 967) ≡ 185 (mod 967)
x ≡ 41 × 23-1 (mod 158) ≡ 41 × 55 (mod 158) ≡ 43 (mod 158)
x ≡ 100 × 59-1 (mod 971) ≡ 100 × 395 (mod 971) ≡ 660 (mod 971)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 967 × 158 × 971 = 148355206
  2. We calculate the numbers M1 to M3
    M1=M/m1=148355206/967=153418,   M2=M/m2=148355206/158=938957,   M3=M/m3=148355206/971=152786
  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
    9671534180967010
    153418967158632101
    967632133501-1
    63233512971-12
    335297138-12-3
    297387312-323
    383117-323-26
    3174323-26127
    7321-26127-280
    3130127-280967
    So our multiplicative inverse is -280 mod 967 ≡ 687
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1589389570158010
    9389571585942121101
    15812113701-1
    121373101-14
    371037-14-13
    107134-1317
    7321-1317-47
    313017-47158
    So our multiplicative inverse is -47 mod 158 ≡ 111
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9711527860971010
    152786971157339101
    971339229301-2
    3392931461-23
    29346617-23-20
    46172123-2043
    171215-2043-63
    1252243-63169
    5221-63169-401
    2120169-401971
    So our multiplicative inverse is -401 mod 971 ≡ 570
    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
    =  (185 × 153418 × 687 +
       43 × 938957 × 111 +
       660 × 152786 × 570)   mod 148355206
    = 11387577 (mod 148355206)


    So our answer is 11387577 (mod 148355206).


Verification

So we found that x ≡ 11387577
If this is correct, then the following statements (i.e. the original equations) are true:
298x (mod 967) ≡ 978 (mod 967)
23x (mod 158) ≡ 41 (mod 158)
59x (mod 971) ≡ 100 (mod 971)

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