Function with arbitrary small period Is there a function f: $\mathbb{R} \to \mathbb{R}$ with arbitrary small period different from $f(x) = k$? ($\forall \epsilon >0  \exists a < \epsilon $ such that f(x) has a periodicity $a$) 
I think the function is the Dirichlet function but I don't know how to prove it properly. 
 A: You're correct.
Let $\epsilon$ be arbitrarily small. You need to prove that there exists some $0<p<\epsilon$ such that $D(x)=D(x+p)$  for all $x\in \mathbb{R}$.
We know that $\epsilon$ is some positive real number, so there exists some $p\in \mathbb{Q}$ such that $0<p<\epsilon$. Let's look at an arbitrary $x\in \mathbb{R}$ and see if our property is satisfied or not:
If $x$ is rational, then $D(x)=1$. Since the sum of two rationals is rational, then $D(x+p)=1$ too.
If $x$ is irrational, then $D(x)=0$. Since the sum of a rational and an irrational is irrational, then $D(x+p)=0$ too.
So if we choose our period to be $p$, our property is satisfied.
A: The main question has been answered in other answers well enough, but I would like to address a few natural follow-up questions. What about continuous functions $f$ with this property?
It turns out that in this case there are no nontrivial solutions - every such function is constant. Here's a topological proof: Let $K=\{x\in\Bbb R\mid \forall y, f(y)=f(x+y)\}$ be the set of periods of $f$. If $f$ is continuous, then this is an intersection of the sets $\{x\in\Bbb R\mid f(y)=f(x+y)\}$, which is closed (it is the preimage of $\{0\}$ under the function $g(x)=f(y)-f(x+y)$), so $K$ itself is closed. $K$ is also dense in $\Bbb R$, because it is an additive group with arbitrarily small elements, so $K=\Bbb R$ and hence $f(x)=f(y)$ for all $x,y\in \Bbb R$.
If we consider discontinuous functions again, then we know $K$ is a dense additive subgroup of $\Bbb R$. Does every dense additive subgroup generate such a function? Yes, we can just take the characteristic function of $K$. For a fixed $K$, the space of such functions is just all functions $\Bbb R/K\to \Bbb R$. This is another way to get at the constancy result, since as a topological group, $\Bbb R/K$ has the indiscrete topology, because any open set will cover $\Bbb R$ if copied around with translations by $K$.
Of course $\Bbb R/K$ can be uncountable, for example if $K=\Bbb Q$ or any other countable subgroup. Can it be countable or finite? It can be countable assuming some choice, as observed in TomGrubb's answer. If we consider a Hamel basis $B$ of $\Bbb R$ over $\Bbb Q$, then the set of all real numbers with zero first projection is a subgroup $K$ of $\Bbb R$ for which $\Bbb R/K\simeq \Bbb Q$.
But it can't be finite (unless it is trivial). In other words, there is no coherent way to talk about real numbers being partitioned into the "even" and "odd" ones. If $\Bbb R/K$ has $n>1$ elements, then that means that every number which is a multiple of $n$ is in $K$; but every real number is a multiple of $n$, to wit, $x=n(x/n)$.
A: Another way to look at it is to think about the set of periods, i.e.
$$P = \{ p \in \mathbb{R} | f(x + p) = f(x) \text{ for all } x \in \mathbb{R} \}$$
Zero is clearly a member of this set no matter what f is.  P is closed under addition and negation.  So clearly P is a group over addition.  So, if you want to find a function that has arbitrarily small periods, you want to find a subgroup of $\mathbb{R}$ that has arbitrarily small values.  $\mathbb{Q}$ is the obvious choice, so the characteristic function for $\mathbb{Q}$ works, as stated in another answer.
A: You're right. The characteristic function of the rationals is periodic of period $1/n$ for all $n \in \mathbb N$ because $x$ is rational iff $x+1/n$ is rational.
A: Here's a different function with the same property (which relies on a fair bit of choice). Choose a Hamel basis for $\mathbb{R}$ over $\mathbb{Q}$ and pick a basis vector $v$. Let $f$ be the function which projects onto the $v$ coordinate. Then for any other basis vector $u$ and any integer $n$,
$$
f(x+u/n)=f(x).
$$
More can be found on these functions in the article "Discontinuous additive functions" by Bernardi.
