TITLE: If $f(\mathbb{R}) \subseteq \mathbb{Q}$, prove that $f$ is constant.
QUESTION [6 upvotes]: Let $f:\mathbb{R}\to \mathbb{R}$ is a function with $f(\mathbb{R})\subseteq \mathbb{Q}$ such that for every Cauchy sequence of rational numbers $(a_i)$, $\lim_{i\to \infty}f(a_i)$ exists. Prove that $f$ is constant. 

If I can prove that $f$ is continuous then I am able to do this problem, I am unable to prove the function is continuous. 
My try:
 Take $x\in \mathbb{R}$. Then there exists a sequence of rational nmber converging to that $x$, say $(x_n)$. After that can't think of what to do next.

REPLY [8 votes]: No. Counter example: $f : \mathbb R\to \mathbb R$, where 
$$f(x) = \begin{cases} 1 & \text{if } x=\sqrt 2 \\ 0 & \text{if } x\neq \sqrt 2.\end{cases}$$
For any $a_n\in \mathbb Q$, $f(a_n) = 0$ and so has a limit. But this $f$ is non-constant.