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://tex.z-dn.net/?f=%5Cbegin%7Bcases%7Dx%5Cequiv5%5Cpmod%7B35%7D%5C%5Cx%5Cequiv5%5Cpmod%7B42%7D%5C%5Cx%5Cequiv5%5Cpmod%7B63%7D%5Cend%7Bcases%7D)
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://tex.z-dn.net/?f=x%5Cequiv5%5Cpmod%7B35%7D%5Cimplies%5Cbegin%7Bcases%7Dx%5Cequiv5%5Cequiv0%5Cpmod5%5C%5Cx%5Cequiv5%5Cpmod7%5Cend%7Bcases%7D)
![x\equiv5\pmod{42}\implies\begin{cases}x\equiv5\equiv1\pmod2\\x\equiv5\equiv2\pmod3\\x\equiv5\pmod7\end{cases}](https://tex.z-dn.net/?f=x%5Cequiv5%5Cpmod%7B42%7D%5Cimplies%5Cbegin%7Bcases%7Dx%5Cequiv5%5Cequiv1%5Cpmod2%5C%5Cx%5Cequiv5%5Cequiv2%5Cpmod3%5C%5Cx%5Cequiv5%5Cpmod7%5Cend%7Bcases%7D)
![x\equiv5\pmod{63}\implies\begin{cases}x\equiv5\equiv2\pmod 3\\x\equiv5\pmod7\end{cases}](https://tex.z-dn.net/?f=x%5Cequiv5%5Cpmod%7B63%7D%5Cimplies%5Cbegin%7Bcases%7Dx%5Cequiv5%5Cequiv2%5Cpmod%203%5C%5Cx%5Cequiv5%5Cpmod7%5Cend%7Bcases%7D)
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://tex.z-dn.net/?f=%5Cbegin%7Bcases%7Dx%5Cequiv1%5Cpmod2%5C%5Cx%5Cequiv2%5Cpmod3%5C%5Cx%5Cequiv0%5Cpmod5%5C%5Cx%5Cequiv5%5Cpmod7%5Cend%7Bcases%7D)
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://tex.z-dn.net/?f=x%3D3%5Ccdot5%5Ccdot7%2B2%5Ccdot5%5Ccdot7%2B2%5Ccdot3%5Ccdot7%2B2%5Ccdot3%5Ccdot5)
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://tex.z-dn.net/?f=x%5Cequiv3%5Ccdot5%5Ccdot7%5Cequiv105%5Cequiv1%5Cpmod2)
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://tex.z-dn.net/?f=x%5Cequiv2%5Ccdot5%5Ccdot7%5Cequiv70%5Cequiv1%5Cpmod3)
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://tex.z-dn.net/?f=x%5Cequiv2%5Ccdot3%5Ccdot7%5Cequiv42%5Cequiv2%5Cpmod5)
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://tex.z-dn.net/?f=x%5Cequiv2%5Ccdot3%5Ccdot5%5Cequiv30%5Cequiv2%5Cpmod7)
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://tex.z-dn.net/?f=x%3D3%5Ccdot5%5Ccdot7%2B2%5E2%5Ccdot5%5Ccdot7%2B0%2B2%5E3%5Ccdot3%5Ccdot5%5E2%3D845)
and from the CRT we find
![x\equiv845\pmod2\cdot3\cdot5\cdot7\implies x\equiv5\pmod{210}](https://tex.z-dn.net/?f=x%5Cequiv845%5Cpmod2%5Ccdot3%5Ccdot5%5Ccdot7%5Cimplies%20x%5Cequiv5%5Cpmod%7B210%7D)
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\dfrac{995}{210}\approx4.7\implies n=5](https://tex.z-dn.net/?f=210n%2B5%5Cge1000%5Cimplies210n%5Cge995%5Cimplies%20n%5Cge%5Cdfrac%7B995%7D%7B210%7D%5Capprox4.7%5Cimplies%20n%3D5)
which gives
.