TITLE: Is every function $f : \mathbb N \to \mathbb N$ a composition $f = g\circ g$?
QUESTION [8 upvotes]: True or wrong: For every function $f: \mathbb N \rightarrow \mathbb N$ there is a function $g: \mathbb N \rightarrow \mathbb N$ with $f=g \circ g$.

REPLY [3 votes]: Shay and Azimut have found the perfect counter-example, and I just want to say a word about how one might come up with such a counter-example.
Let $S_n$ be the symmetric group on $\{1, \dots, n\}$. A necessary condition for a permutation $\sigma \in S_n$ to admit a square root is that it be even: indeed, the squares of $S_n$ all lie in the kernel of the sign $S_n \to \{\pm 1\}$.
With this in mind, the permutation of $\mathbf N$ which switches $1$ and $2$ is a natural candidate for a function which has no square root. Indeed, if one could speak of its sign, it should be negative. Unfortunately, one cannot speak of the sign of an arbitrary permutation of $\mathbf N$. One can, however, speak of the sign of a permutation which is almost everywhere the identity. Permutations of $\mathbf N$ which leave almost all elements fixed form a subgroup of the group of all permutations of $\mathbf N$, which identifies with the direct limit $\mathbf S_{\infty}$ of the direct system $S_1 \to S_2 \to S_3 \to \dots$. The sign homomorphisms are compatible with the maps of the direct system, and determine a sign homomorphism $\mathbf S_{\infty} \to \{\pm 1\}$. Azimut and Shay's map is an "odd" element of $\mathbf S_{\infty}$, and therefore cannot admit a square root inside $\mathbf S_{\infty}$. 
Unfortunately, this is not sufficient to see that their map admits no square root, because there are permutations of $\mathbf N$ which are not in $\mathbf S_{\infty}$, but whose square is. Thus, one still needs to argue (as they do) that their map cannot admit a square root in the bigger group $S_{\mathbf N}$. But perhaps, it is still interesting to have this source of intuition!