Define a function $f$ on the real numbers by

$$
f(x)= \begin{cases}2 x & \text { if } x<1 / 2 \\ 2 x-1 & \text { if } x \geq 1 / 2\end{cases}
$$

Determine all values $x$ satisfying $f(f(f(f(f)))))=x$.
The answer is the 32 values $0, \frac{1}{31}, \frac{2}{31}, \ldots, \frac{30}{31}, 1$.

If $x1$, similarly $f(x)=2 x-1>x$ so the sequence $x, f(x), f(f(x)), \ldots$ is strictly increasing and cannot return to $x$.

If $x=1$, then $f(x)=1$ and we have 1 as a solution.

Finally, we assume that $0 \leq x<1$, so $0 \leq f(x)<1$ as well. For simplicity let $x_{0}=x$ and $x_{n+1}=f\left(x_{i}\right)$ so the equation we are trying to solve is $x_{5}=x_{0}$. Note that $2 x_{n}-x_{n+1}$ is an integer (either 0 or 1 ) for each $n$, so

$$
32 x_{0}-x_{5}=16\left(2 x_{0}-x_{1}\right)+8\left(2 x_{1}-x_{2}\right)+4\left(2 x_{2}-x_{3}\right)+2\left(2 x_{3}-x_{4}\right)+\left(2 x_{4}-x_{5}\right)
$$

must be an integer as well. If we assume $x_{5}=x_{0}$ we deduce that $31 x_{0}$ is an integer. Conversely, if $31 x_{0}$ is an integer, then $x_{5}-x_{0}$ is an integer and this integer must be 0 because $0 \leq x_{0}, x_{5}<1$. Thus the solutions in this range are exactly the multiples of $\frac{1}{31}: 0, \frac{1}{31}, \frac{2}{31}, \ldots, \frac{30}{31}$.