Let $E=\{a, b, c, d\}$ be a set. How many functions $f$ from $E$ to $E$ satisfy, for all $x$ in $E, f(f(f(x)))=x$?
The identity, defined for all $x$ by $f(x)=x$, is obviously a solution. If one of the elements has an image distinct from itself, for example $f(x)=y$, what can $f(y)$ be equal to? If we had $f(y)=x$, we would have: $f(f(f(x)))=f(f(y))=f(x)=y$, the relation from the hypothesis would not be satisfied. Similarly, if we had $f(y)=y$. It follows that $f(y)=z$ distinct from $x$ and $y$, and $f(z)=f(f(f(x)))=x$. The function cyclically permutes three of the elements $x, y, z$ of the set, and leaves the last one $t$ invariant. Indeed, if we had $f(t) \in\{x, y, z\}$, we would also have $f(f(f(t))) \in\{x, y, z\}$, which would contradict $f(f(f(t)))=t$. To define one of these functions, it suffices to determine its "fixed point" (element $t$ such that $f(t)=t$), and then the direction of the cyclic permutation of the other three elements, which gives $4 \times 2=8$ functions, plus the identity, for a total of 9.