L OM - II - Task 5

Let $ S = \{1, 2,3,4, 5\} $. Determine the number of functions $ f: S \to S $ satisfying the equation $ f^{50} (x) = x $ for all $ x \in S $.
Note: $ f^{50}(x) = \underbrace{f \circ f \circ \ldots \circ f}_{50} (x) $.
Let $ f $ be a function satisfying the conditions of the problem. For numbers $ x \neq y $, we get $ f^{49}(f(x)) = x \neq y = f^{49}(f(y)) $, hence $ f(x) \neq f(y) $. Therefore, $ f $ is a permutation of the set $ S $. Denote by $ r(x) $ ($ x \in S $) the smallest positive integer such that $ f^{r(x)}(x) = x $. Then $ r(x) \leq 5 $ and $ r(x) \mid 50 $, so $ r(x) \in \{1, 2, 5\} $. 
If there exists a number $ a \in S $ such that $ r(a) = 5 $, then the numbers $ a $, $ f(a) $, $ f^2(a) $, $ f^3(a) $, $ f^4(a) $ are distinct; they thus exhaust the set $ S $. Then for any number $ x \in S $, $ r(x) = 5 $. The function $ f $ is thus uniquely determined by the permutation $ (f(1), f^2(1), f^3(1), f^4(1)) $ of the set $ \{2, 3, 4, 5\} $; hence it can be defined in $ 4! = 24 $ ways. 
If for all $ x \in S $, $ r(x) = 1 $, then $ f $ is the identity function. Such a function is unique. 
The remaining case to consider is when the maximum value attained by the function $ r $ is $ 2 $. Let $ a $ be an element of the set $ S $ such that $ r(a) = 2 $. Then also $ r(b) = 2 $, where $ b = f(a) $. 
If $ r(x) = 1 $ for all $ x \in S \setminus \{a, b\} $, then $ f $ is determined by the choice of a two-element subset $ \{a, b\} $ of the set $ S $, which can be done in $ {5 \choose 2} = 10 $ ways.
If, however, there exists a number $ c \in S \setminus \{a, b\} $ such that $ r(c) = 2 $, then by setting $ d = f(c) $ and denoting by $ e $ the unique element of the set $ S \setminus \{a, b, c, d\} $, we have

Such a function $ f $ is determined by the choice of the number $ e $ (which can be done in $ 5 $ ways) and the partition of the set $ S \setminus \{e\} $ into two two-element subsets $ \{a, b\} $ and $ \{c, d\} $ (there are $ 3 $ such partitions). We thus get $ 15 $ functions of the form (1). 
In total, there are $ 50 $ functions satisfying the conditions of the problem.