The smallest such number is 1055.
We want to find
such that
![\begin{cases}x\equiv5\pmod{35}\\x\equiv5\pmod{42}\\x\equiv5\pmod{63}\end{cases}](https://img.qammunity.org/2019/formulas/mathematics/middle-school/cyrnucsibkvvtdu25gll8fetzz7xcwzb6j.png)
The moduli are not coprime, so we expand the system as follows in preparation for using the Chinese remainder theorem.
![x\equiv5\pmod{35}\implies\begin{cases}x\equiv5\equiv0\pmod5\\x\equiv5\pmod7\end{cases}](https://img.qammunity.org/2019/formulas/mathematics/middle-school/9x80cwa8aq9cs6bq8m7hy6tprtxe09xakw.png)
![x\equiv5\pmod{42}\implies\begin{cases}x\equiv5\equiv1\pmod2\\x\equiv5\equiv2\pmod3\\x\equiv5\pmod7\end{cases}](https://img.qammunity.org/2019/formulas/mathematics/middle-school/r1uuzxeg9u35gth58nj6w6tr00udp4m8vx.png)
![x\equiv5\pmod{63}\implies\begin{cases}x\equiv5\equiv2\pmod 3\\x\equiv5\pmod7\end{cases}](https://img.qammunity.org/2019/formulas/mathematics/middle-school/oceztxkrotknjnhoo41aveskkp2i9u1rxi.png)
Taking everything together, we end up with the system
![\begin{cases}x\equiv1\pmod2\\x\equiv2\pmod3\\x\equiv0\pmod5\\x\equiv5\pmod7\end{cases}](https://img.qammunity.org/2019/formulas/mathematics/middle-school/ooi2tusw6sf8irgh1atbo0f1wk6c4m9pxg.png)
Now the moduli are coprime and we can apply the CRT.
We start with
![x=3\cdot5\cdot7+2\cdot5\cdot7+2\cdot3\cdot7+2\cdot3\cdot5](https://img.qammunity.org/2019/formulas/mathematics/middle-school/uidppo9b40ydo1sb2zx3ipww1m7uzh9qo6.png)
Then taken modulo 2, 3, 5, and 7, all but the first, second, third, or last (respectively) terms will vanish.
Taken modulo 2, we end up with
![x\equiv3\cdot5\cdot7\equiv105\equiv1\pmod2](https://img.qammunity.org/2019/formulas/mathematics/middle-school/art9gyassbql8n0xaj4y4r04n76kr43nh8.png)
which means the first term is fine and doesn't require adjustment.
Taken modulo 3, we have
![x\equiv2\cdot5\cdot7\equiv70\equiv1\pmod3](https://img.qammunity.org/2019/formulas/mathematics/middle-school/qatxq4cpnb6nji96jk3ycm6obwn8nmj660.png)
We want a remainder of 2, so we just need to multiply the second term by 2.
Taken modulo 5, we have
![x\equiv2\cdot3\cdot7\equiv42\equiv2\pmod5](https://img.qammunity.org/2019/formulas/mathematics/middle-school/x323226ijof733f5xujhkpqp3qbpxgxcyu.png)
We want a remainder of 0, so we can just multiply this term by 0.
Taken modulo 7, we have
![x\equiv2\cdot3\cdot5\equiv30\equiv2\pmod7](https://img.qammunity.org/2019/formulas/mathematics/middle-school/oxq4jnbbr9sddtaezg3zca8iggrw2cg91g.png)
We want a remainder of 5, so we multiply by the inverse of 2 modulo 7, then by 5. Since
, the inverse of 2 is 4.
So, we have to adjust
to
![x=3\cdot5\cdot7+2^2\cdot5\cdot7+0+2^3\cdot3\cdot5^2=845](https://img.qammunity.org/2019/formulas/mathematics/middle-school/bvhdcnn18d7er6siyark0gmzxrb57sy86e.png)
and from the CRT we find
![x\equiv845\pmod2\cdot3\cdot5\cdot7\implies x\equiv5\pmod{210}](https://img.qammunity.org/2019/formulas/mathematics/middle-school/hdfoiy1sbflyuy4humz4xaz7zorr5y87ap.png)
so that the general solution
for all integers
.
We want a 4 digit solution, so we want
![210n+5\ge1000\implies210n\ge995\implies n\ge(995)/(210)\approx4.7\implies n=5](https://img.qammunity.org/2019/formulas/mathematics/middle-school/o5w3si0ruc7driykoj0dvhdu20q5nalj4y.png)
which gives
.