How many functions can be constructed? How many functions $f:\left\{1, 2, 3, 4,5 \right\} \rightarrow \left\{ 1, 2, 3, 4, 5 \right\}$ satisfy the relation $f\left( x \right) =f\left( f\left( x \right)  \right)$ for every $x\in \left\{ 1, 2, 3, 4, 5 \right\}$?
My book says the answer is 196.

Hint:  Let $R\subset\{1,2,3,4,5\}$ be the range of $f$.
Then $f(x)$ is completely determined  for every $x\in R$, and the only choices you have about the behavior of $f$ are for $x\notin R$.
Hint 2: If $\{1,2,3,4,5\}$ is too complicated, try solving the problem for $\{1,2\}$ instead, and then see if you can apply the same method to the $\{1,2,3,4,5\}$ case.
Hint 3:  Suppose that $R$ has exactly $n$ elements, and then try to count the number of functions $f$ satisfying $f(f(x))=f(x)$.
