The conditions of the problem give two representations for $f(f(f(x)))$ :

$$
f(f(f(x)))=a f(f(x))=a^{2} f(x)
$$

and

$$
f(f(f(x)))=f(a f(x))=a^{2} f(f(x))=a^{3} f(x) .
$$

So $a^{2} f(x)=a^{3} f(x)$ for all $x$, and if there is an $x$ such that $f(x) \neq 0$, the $a=0$ or $a=1$. Otherwise $f$ is the constant function $f(x)=0$ for all $x$. If $a=1$, the function $f(x)=x$ satisfies the conditions. For $a=0$, one possible solution is the function $f$,

$$
f(x)=\left\{\begin{array}{ll}
1 & \text { for } x<0 \\
0 & \text { for } x \geq 0
\end{array} .\right.
$$
Find all real numbers a for which there exists a non-constant function $f: \mathbb{R} \rightarrow \mathbb{R}$ satisfying the following two equations for all $x \in \mathbb{R}$ :
i) $\quad f(a x)=a^{2} f(x)$ and

ii) $f(f(x))=a f(x)$.