A polynomial problem, Source: AOPS Let $f(x)$ be a polynomial of real coefficients such that if $n\equiv 5 \pmod{10}$ or $n\equiv 8\pmod{10}$, then $f(n)$ is an integer ($n$ is an integer). Is it true that $f(0)$ is an integer?
I am sure the answer is yes. But why? Please help!
 A: Suppose $f \in \mathbb{C}[x]$ is such that $f(10u+5)$ and $f(10u+8)$ are integers, for all integers $u$.

Claim:$\;f(0)$ is an integer.

Proof:

Since $f(v)$ is an integer for infinitely many integers $v$, it follows, by Lagrange interpolation, that $f$ has rational coefficients.

Let $g\in\mathbb{Q}[x]$ be such that $f(x)=xg(x) + f(0)$.

Let $G\in \mathbb{Z}[x]$ be such that $g(x) = {\large{\frac{G(x)}{D}}}$, where $D$ is a positive integer.

Write $D=(2^a)(5^b)D'$, where $a,b$ are nonnegative integers, and $D'$ is a positive integer, with $\gcd(D',10)=1$.

Choose $m,n\in\mathbb{Z}$ such that 


*

*$D'{\,\mid\,}(2m+1)$, and $5^b{\,\mid\;}5(2m+1)$$\\[4pt]$

*$D'{\,\mid\,}(5n+4)$, and $2^a{\,\mid\;}2(5n+4)$


Then
\begin{align*}
&f(10m+5)\in \mathbb{Z}\\[4pt]
\implies\;&(10m+5)g(10m+5)+f(0)\in \mathbb{Z}\\[4pt]
\implies\;&\left(5(2m+1)\frac{G(10m+5)}{D}\right)+f(0)\in \mathbb{Z}\\[4pt]
\implies\;&2^af(0)\in \mathbb{Z}
\end{align*}
and
\begin{align*}
&f(10n+8)\in \mathbb{Z}\\[4pt]
\implies\;&(10n+8)g(10n+8)+f(0)\in \mathbb{Z}\\[4pt]
\implies\;&\left(2(5n+4)\frac{G(10n+8)}{D}\right)+f(0)\in \mathbb{Z}\\[4pt]
\implies\;&5^bf(0)\in \mathbb{Z}
\end{align*}
hence, when reduced to lowest terms, the denominator of $f(0)$ is both a power of $2$ and a power of $5$.

It follows that $f(0)$ is an integer.
A: Suppose $f$ is linear.
Then
$f(n) = an+b$.
$f(10n+5)
=a(10n+5)+b
=50n+5a+b
$ 
and
$f(10m+8)
=a(10m+8)+b
=50m+8a+b
$.
Since these are integers,
as are $n$ and $m$,
so are
$5a+b=u$
and
$8a+b=v$.
Therefore
$8u-5v
=3b$
is an integer.
Similarly,
$5u-3v
=a+2b
$
is an integer.
Therefore
$3a = 3(a+2b)-2(3b)$
is an integer.
(Also from
$v-u = 3a$)
If
$a=b=\frac13$,
then
$5a+b = 2$
and
$8a+b = 3$,
so
$\frac13 n+\frac13$
works
without integer coefficients.
