Let $f:\mathbb{R}\rightarrow \mathbb{R}$ be a differentiable nonconstant function with $f(f(x))=f(x)$ for all $x\in \mathbb{R}$. Prove that the range of the fucntion is all of $\mathbb{R}$.
All that I have gotten is for all $x$, either $f'(x)=0$ or $f'(f(x))=1$ should hold. Also that for all $x$ in the range of $f$, $f(x)=x$. Proving that the function is unbounded would do it. How do I proceed from here ?