TITLE: Continuous extensions reals and to p-adic numbers
QUESTION [7 upvotes]: Assume $f\colon \mathbb Q\to  \mathbb Q$ is a function which admits continuous extensions

$f_0\colon\mathbb R\to  \mathbb R$ and 
$f_p\colon \mathbb Q_p\to  \mathbb Q_p$ for each prime $p$.


Is it true that $f$ is a polynomial?

I guess the answer is no, but I do not see a counterexample.

REPLY [14 votes]: The answer is no, and one can essentially use the same construction as in the answer:
Is a real power series that maps rationals to rationals defined by a rational function?
Specifically, enumerate the non-zero rationals $\{r_1,r_2,  \ldots\}$ in some way. Now consider the function:
$$f(x) = \sum_{n=1}^{\infty} c_n x^{n^2} \prod_{i=1}^{n} (x - r_i).$$
If $c_n \in \mathbf{Q}$, then this is a well defined function from rationals to rationals.
On the other hand, $f(x)$ converges to an analytic function in $\mathbf{Q}_v$ if and only if the coefficients of this power series converge to zero fast enough.
Since the coefficients of the power series in the range $k = n^2$ to $k < (n+1)^2$
are simply the cofficients of $c_n x^{n^2} \prod_{i=1}^{n} (x - r_i)$, this can be ensured
by forcing these coefficients to be very highly divisible by the first $n$ primes, and small in the  archimedean sense (by including a very very large prime in the denominator).