Let $S = \{1, 2, 3, 4\}$, and let $F$ be the sets of all functions from $S$ to $S$.
How many functions exist such that $(f \circ f)(1) = 2$?
How many functions exist such that $(f \circ f)(1) = 2$, and $f$ is onto?
I'm not sure how to approach this problem really, any hints to help me count how many of these functions exist? Thanks in advance :)
Hint. If $f(f(1))= 2$ then $f(1)\not=1$. Hence $[f(1),f(2),f(3),f(4)]$ could be $$[2,2,?,?],\;[3,?,2,?],\;[4,?,?,2].$$ For the first question we can replace any ? with $1$, $2$, $3$, or $4$.
For the second question note that any onto function from $S$ to $S$ is a bijection!