On the Subject of Chinese Remainder Theorem
More like... Chinese Remainder TFCeorem!
- Note down all of the module’s equations
N % A = B(which there will be 4 to 8 of), pressing the equation display to cycle through them. -
Introduce variables
athroughc-g, one for each equation excluding one (e.g. you should introduce variablesa,b,c,d, andeif you have 6 equations), all initially equal to 0. -
Introduce a variable
N, equal toB + A*a, whereAandBare taken from any of the noted module’s equations. Remove the said equation from your notes. - Start with the
avariable being your current letter variable. -
If there is a noted equation that is met by the current value of
N:- If this is the last remaining noted equation, remove it from your notes, then input and submit
N’s value into the module to solve it. -
Otherwise, set the current letter variable to be equal to
v + A*n, where:vis the value of the variable at this point.Ais taken from the aforementioned equation.nis the letter variable that follows the current letter variable.
- Remove the said equation from your notes.
- Move on to the next letter variable (
n) being your current letter variable, and check Step 5’s condition again.
- If this is the last remaining noted equation, remove it from your notes, then input and submit
- Otherwise, increment the value of the current letter variable, then check Step 5 again.
Example
The module’s equations are:
#1: N % 21 = 15
#2: N % 29 = 20
#3: N % 17 = 5
#4: N % 39 = 36
#5: N % 20 = 6
Introducing four variables for the five noted equations: a, b, c, and d.
Introducing N = 15 + 21*a, where A and B were taken from equation #1.
Removing equation #1 from notes - equations #2, #3, #4, and #5 are still left.