Chinese remainder theorem - how to find ALL the N in a specified range (not just the smallest)?

438 Views Asked by At

Question:

A Chinese remainder theorem algorithm finds the smallest $N$, is it possible to find ALL the N in a specified range?

For example:

$N \equiv 2\mod3$

$N \equiv 3\mod5$

$N \equiv 2\mod7$

Gives us the smallest answer: $N = 23$

How to get all the $N$ in range $1 - 1000$ ?

2

There are 2 best solutions below

1
On BEST ANSWER

The answer you have, $N=23$, is one example of $N\equiv 23 \bmod 105$. The modulus there arises from $105=\text{lcm}(3,5,7)$, and the Chinese Remainder theorem tells us that the value of $23$ is a unique solution in the range $(0,104)$. So the solutions will be separated by the modulus interval: $23, 128,\ldots$.

0
On

$N\equiv 23 \pmod {105} \implies N=105k+23 $ for any non negative $k$ (as limit of your $N$ starts from $1$).

So to obtain values of $N$ in your range, keep plugging $k=0,1,2..$ until $N$ exceeds $1000$.