TITLE: Polynomials with non integral results for multiples of 10
QUESTION [11 upvotes]: As challenge problem, my teacher challenged us to find a polynomial $f(x)$ that would return an integer for all positive integral values of $x$ except for some (possibly not all) $x$ divisible by $10$. For example, we could have some polynomial $g(x)$ in which $g(1)=1$, but $g(10)=0.1$ and $g(20)=2$. (I'm just making up numbers here.) I've been bashing my head at this, and have tried raising $x$ to the fourth power to eliminate the units digits down to $0,1,5,6$, but have had no such luck. Is this an impossible problem? If not, could I maybe see an example of a such polynomial, and why it would work?

REPLY [5 votes]: A general answer is something like this:
(i) For every prime power $p^k$ there exists a polynomial $f(x)$ such that for every $a\in\mathbb{Z}$, $f(a)$ is an integer if and only if $p^k$ does not divide $a$. For instance, $f(x)=\frac1p \cdot \frac{(x+1)(x+2)\ldots(x+p^k-1)}{(p^k-1)!}$ is such a polynomial.
(ii) If $m$ is a positive integer with at least two distinct prime factors, and $f(x)$ is a polynomial with the property that $f(a)$ is an integer whenever $m$ does not divide $a$, then $f(a)$ is integer for all integers $a$.
To prove (ii) it is sufficient to prove that $f(0)$ is an integer. Let $p$ and $q$ be two distinct prime divisors of $m$. From Lagrange's interpolation we know that $f$ has rational coefficients; take a positive integer $M$ such that $g(x)=Mf(x)$ has integer coefficients. 
Then there are some positive integers $M_1$ and $M_2$ such that $M_1M_2=M$, $M_1$ and $M_2$ are coprime, $M_1$ is coprime with $p$ and $M_2$ is coprime with $q$. None of $M_1$ and $M_2$ is divisble by $m$, so $f(M_1)$ and $f(M_2)$ are integers. Hence,
$$ Mf(0) = g(0) \equiv g(M_1) = Mf(M_1) \equiv 0 \pmod{M_1} $$
and similarly
$$ Mf(0) \equiv Mf(M_2) \equiv 0 \pmod{M_2}. $$
Since $M_1$ and $M_2$ are coprime, we get
$Mf(0) \equiv 0 \pmod{M}$, so $f(0)$ is an integer.

See also the 2nd problem of RMM2011 at
http://rmms.lbi.ro/rmm2011/_dwl/Sols2011D1.pdf