If the function is one-to-one we have only one case. f(x)=x
If not:
Let us consider a permutation of the set A({1,2,......,n}) to be {a1,a2,.....,an}
The idea is to divide the set into subsets {b1,b2,......,bk} such
f(b_1)=f(b_2)=.....=f(b_i)=.....=f(b_k)=b_i
see that the condition f(f(x))=f(x) is satisfied.
To evaluate this we consider the sets D{1,2,3,......,n} and R{1,2,3,......,n}
When we have k subsets(following the conditions mentioned above):
We choose k numbers from R.We obtain Rk{a1,a2,.....,ak} This can be done in \begin{pmatrix} n\\k \end{pmatrix} ways.
Now we have to map the numbers of D to Rk in such a manner that ai in D always maps to ai in Rk. This can be done in k^{n-k} ways(?).
So for dividing into k groups we have {\begin{pmatrix} n\\k \end{pmatrix}k^{n-k}} ways.
Total number of ways= \sum_{1}^{n}{\begin{pmatrix} n\\k \end{pmatrix}k^{n-k}}
Don't know how to simplify this.
Is it correct?...
P.S. Recurrence relation may be used but I could not get any.