Problem

Source: Dutch IMO TST1 2019 p2

Tags: function, algebra



Write $S_n$ for the set $\{1, 2,..., n\}$. Determine all positive integers $n$ for which there exist functions $f : S_n \to S_n$ and $g : S_n \to S_n$ such that for every $x$ exactly one of the equalities $f(g(x)) = x$ and $g(f(x)) = x$ holds.