Let $A = \{1,2,3,4\}$. Number of functions $f :A \to A$, such that $f(f(x))=x~\forall x \in A$ , is. 
Let $A = \{1,2,3,4\}$. Number of functions $f :A \to A$, such that $f(f(x))=x,  \forall x \in A$ , is.

For this , what I thought was 2 cases are possible. Either an element maps to itself or 2 elements map to each other.
Eg either $1 \to 1$ or $1 \to 2$ and $2 \to 1.$
So for this I can group the elements in groups of 2 in $^4C_2 $ways. Then say I group $(a,b)$ and$ (c,d)$ . Then $ a$ can either map to $a$ or $b$. The other element from that group will automatically be defined. Similarly for $(c,d)$
So the answer should be $^4C_2× 2×2 = 24$ . But the answer is

$13$

Please help.
 A: Case 1: There are 4 fixed points. The only such involution is the identity.
Case 2: There are 2 fixed points. In this case, once 2 elements are fixed, the remaining 2 elements must map to each other. Hence, the number of involutions with 2 fixed points is $\binom{4}{2} = 6$.
Case 3: The involution is a derangement (fixed-point-free). In this case, the number 1 must map to 2, 3, or 4, and whatever 1 maps to must be mapped to 1. Then, the remaining 2 elements must map to each other. Hence, the number of involutions without any fixed points is 3.
In total, there are 10 involutions on a 4-element set like $A = \{1, 2, 3, 4\}$.
A: Jack Schmidt's answer here can help you figure out the elements of $S_4$.
https://math.stackexchange.com/a/379912/399263
Elements of order $2$ are:


*

*the $6$ transpositions $(1,2)\quad (1,3)\quad (1,4)\quad (2,3)\quad (2,4)\quad (3,4)$ 

*the $3$ products of disjoint transpositions $(1,2)(3,4)\quad (1,3)(2,4)\quad (1,4)(2,3)$
Note that since the transpositions are disjoint, $(i,j)(k,l)$ is the same as $(k,l)(i,j)$, do not count double transpositions twice.
And you have to add the identity to these, giving a total of $6+3+1=10$ involutions.
