A function is defined as $g:\{1,2,3,4\}\rightarrow \{1,2,3,4\}$ such that $g(g(x))=g(x)\forall x\{1,2,3,4\}.$ Then number of such functions are
Try: from $g(g(x))=g(x)$ implies $g(x)=x$Identity function , only one function exists.$\bigg(g(1)=1,g(2)=2,g(3)=3\bigg)$
or $g(x)=y\rightarrow g^{-1}(y)=x$ and $g(y)=x\rightarrow g^{-}(x)=y$
We have $8$ such function . Like if $g(1)=1,$ Then dearrangement of remaining $3$ objects which is $2$ So we have total $9$ function. But answer is $10$
Could some help me to solve it, thanks
You seem to be assuming that $g$ is bijective but the problem does not specify that. $g(x)=1$ is an example of a function that meets the requirement but is not bijective. I would claim there are many more than $10$. You need to choose a nonempty subset of $\{1,2,3,4\}$ to be taken to themselves. There are $15$ choices for that. When the subset is not all of $\{1,2,3,4\}$ each element that is not mapped to itself can be mapped to any of the elements that are. An example would be $g(1)=1,g(2)=2,g(3)=1,g(4)=2$. Our answer is to take $i$ as the number if idempotent elements so $$\sum_{i=1}^4{4 \choose i}i^{(4-i)}=41$$ per Alpha