TITLE: Showing the derivative of this function is equal to $0$
QUESTION [5 upvotes]: Define $f:[0,1]\to [0,1]$ by
$$f(x)=\begin{cases}0, &x=0,\\ \\ \sum\limits_{r_n<x } 2^{-n}, & 0 \lt x \le 1, \end{cases} $$
where $\{r_n \}_{n\in \mathbb N} =\mathbb  Q \cap (0,1) $.
How to show that the derivative $f'(x)=0$ a.e.?
I can show this function is increasing and discontinuous at every rational, and  how to word on?

REPLY [3 votes]: The following is the elementary answer that Pietro Majer gave to this question on MO. I copy the answer here so we can consider this question answered. 
Consider the nested family of open nbd's of $(0,1)\cap\mathbb{Q}\ :$   $$A_\epsilon:=\cup_{n\in\mathbb{Z} _ + } (r_n- \epsilon 2^{-n/3},r_n+ \epsilon 2^{-n/3})\ , \qquad \epsilon > 0\ . $$
So $|A _\epsilon|=O(\epsilon)$ and $A:=\cap _  {\epsilon > 0} A _ \epsilon$ has measure zero. Let $x \in (0,1) \setminus A$: There exists $\epsilon > 0$ such that for any $n\in\mathbb{Z}_+$ there holds $  \epsilon 2^{-n/3}\le |x-r_n|$. Thus, for any $y\in (0,1)$ 
$$|f(x)-f(y)|\le  \sum_{|x- r _ n|\le|x- y| } 2^{-n}= \frac{1}{\epsilon^2}\sum_{|x- r _ n|\le|x- y| } 2^{-n/3}(\epsilon 2^{-n/3})^2\le $$
$$\le \frac{1}{\epsilon^2}\bigg(\sum_{n=1}^\infty  2^{-n/3}\bigg)|x-y|^2= \frac{|x-y|^2}{\epsilon^2(2^{1/3}-1))}\ ,$$ showing that $f'(x)=0\ .$