# Function which is $2^n$ - periodic for all integers $n$

Is there a non-constant, continuous function $f: \mathbb{R} \longrightarrow \mathbb{R}$ such that for all integers $n$, $f$ is $2^n$-periodic?

Notes:

1. $n$ can be any integer, and so can be negative as well as positive.
2. If I did not require $f$ to be continuous, then I think $f: \mathbb{R} \longrightarrow \mathbb{R}$ defined by: $$f(x) = \begin{cases} 1 & \text{x rational} \\ 0 & \text{x irrational} \end{cases}$$ would do the trick.

No, such a function does not exist. Assume there are two points $x,y$ with $f(x)=a, f(y)=b, a \ne b$. The points with function value $a$ are dense in the real line because they include all offsets by any dyadic rational, so I can find one arbitrarily close to $y$.
Added: we can characterize the $2^n$ periodic functions. Define an equivalence relation on $\mathbb R$ by $x \sim y$ if $x-y$ is a dyadic rational. There are continuum many classes, each countable and dense. The function must be constant on any given class, but there is no restriction between the classes. That means there are as many $2^n$ periodic functions as all functions from $\mathbb R$ to $\mathbb R$
No such function exists. Suppose $f$ is non-constant, so we have some $a<b$ and $\epsilon>0$ such that $|f(a)-f(b)|>\epsilon$. By continuity, we have some $\delta>0$ such that $|x-y|<\delta\implies |f(x)-f(y)|<\epsilon$. Let $n\in\mathbb Z$ be such that $2^n<\delta$, and let $m=\lfloor|a-b|/2^n\rfloor$. Then we have \begin{align} |f(a)-f(b)|&\leq |f(a)-f(a+2^n)|+|f(a+2^n)-f(a+2\cdot 2^n)|+\cdots+|f(a+m\cdot 2^n)-f(b)|\\ &\leq |f(a+m\cdot 2^n)-f(b)|<\epsilon\\ \end{align} which is a contradiction.