TITLE: Is there a function $f\colon\mathbb{R}\to\mathbb{R}$ such that every non-empty open interval is mapped onto $\mathbb{R}$?
QUESTION [12 upvotes]: I wonder  whether there is a function $f\colon\Bbb R\to\Bbb R$ with the folowing characteristic? 

for every two real numbers $\alpha,\beta,\alpha\lt\beta$,

$$\{f(x):x\in(\alpha,\beta)\}=\Bbb R$$

I can't  say such a function does not exist, neither can I construct a example
Thanks a lot!

REPLY [7 votes]: My answer to this question is precisely such a function, constructed in an easy way:
There is in fact a rather easy example of a function $\mathbb R \to \mathbb R$ such that the image of every open set is $\mathbb R$: Let $(x_i)_{i\in\mathbb Z_+}$ be the binary decimal expansion of $x$, so that each $x_i\in\{0,1\}$. Let then
$$f(x)=\sum_{k=1}^∞\frac{(−1)^{x_k}}k\quad \textrm{if the series converges}$$
$$f(x)=0\quad\textrm{otherwise.}$$
Since the harmonic series (or a tail of it) can be made to converge to any real number by changing signs in the appropriate way, this function has $f((a,b))=\mathbb R$ for any real $a,b$. 
The harmonic series can be substituted with any other unbounded series where the summand goes to zero.