(M) Find the functions $f: \mathbb{N} \rightarrow \mathbb{N}$ such that for all $n$ we have

$$
f(n)+f(f(n))+f(f(f(n)))=3 n
$$
$f$ is injective and is surjective onto $3 \mathbb{N}$. We have $f(0)+f(f(0))+f^{3}(0)=0$ and by positivity and injectivity we have $f(0)=0$.

Then $f(1)+f^{2}(1)+f^{3}(1)=3$ and since $f(1) \neq 0$ we have $f(1)=1$.

In short, we reason by induction assuming that for $k \geqslant 0$ we have $f(0)=0, \ldots, f(k)=k$ and then $f(k+1)>k+1$ by injectivity but

$$
f(k+1)+f^{2}(k+1)+f^{3}(k+1)=3(k+1)
$$

so if $f(k+1)>k+1$ we have $f^{2}(k+1), f^{3}(k+1) \geqslant k+1$ so it is absurd. Finally, $f=I d$ is the unique solution.