$f\colon\{1,2,3,4,5\}\longrightarrow\{1,2,3,4,5\}$ Find the total number of functions such that $f(f(x))=f(x)$ I tried to solve it by letting $f(x)=y$
then equation reduces to $f(y)=y$ but i didn't get it further.
Please give me hint to solve this from where I should start
 A: You have a very good starting point: for all $x$ in your set, $y=f(x)$ is a fixed point.
Conversely, suppose $f$ maps elements to fixed points, then it clearly satisfies $f(f(x))=f(x)$.
So the answers looks like: choose a subset of $\{1,2,3,4,5\}$ to be the fixed points of your function, and then map the remaining points arbitrarily to these fixed points. A few choices of $f$ are:
1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1
1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 5
1 => 1, 2 => 1, 3 => 1, 4 => 4, 5 => 1
1 => 1, 2 => 1, 3 => 1, 4 => 4, 5 => 4
1 => 1, 2 => 1, 3 => 1, 4 => 4, 5 => 5
1 => 1, 2 => 1, 3 => 1, 4 => 5, 5 => 5
1 => 1, 2 => 1, 3 => 3, 4 => 1, 5 => 1
1 => 1, 2 => 1, 3 => 3, 4 => 1, 5 => 3
1 => 1, 2 => 1, 3 => 3, 4 => 1, 5 => 5
1 => 1, 2 => 1, 3 => 3, 4 => 3, 5 => 1
1 => 1, 2 => 1, 3 => 3, 4 => 3, 5 => 3
1 => 1, 2 => 1, 3 => 3, 4 => 3, 5 => 5
1 => 1, 2 => 1, 3 => 3, 4 => 4, 5 => 1
1 => 1, 2 => 1, 3 => 3, 4 => 4, 5 => 3
1 => 1, 2 => 1, 3 => 3, 4 => 4, 5 => 4
1 => 1, 2 => 1, 3 => 3, 4 => 4, 5 => 5
1 => 1, 2 => 1, 3 => 3, 4 => 5, 5 => 5
1 => 1, 2 => 1, 3 => 4, 4 => 4, 5 => 1

The list goes on.
A: If a variable $x$ is in the range of $f(x)$, then $f(x)=x$. This means that we can effectively categorize the potential functions by their range. The number of functions that have a given range is $n^{5-n}$, with $n$ being the number of values in the range. The number of ranges that have $n$ values in them is $\frac{5!}{n!(5-n)!}$. This means that the total number of functions is $$\sum_{n=1}^5\frac{5!}{n!(5-n)!}n^{5-n}$$which comes out to be $196$.
