To clarify, A is set containing 9 elements (1-9). To tackle the problem, I first count
How many functions $f : A \to A$ so that $(f\circ f)(1) = 2$?
To which the answer I got is $8 \cdot 1 \cdot 9^7$
Then to get
How many functions $f : A \to A$ so that $(f\circ f)(1) = 2$ and f is onto?
what I would do is $8 \cdot 1 \cdot 9^7$ - not onto functions.
I'm not 100% sure how many not onto functions are there given $(f\circ f)(1) = 2$. I want to say $7!$ not onto functions then the answer is $8 \cdot 1 \cdot 9^7$ - $7!$
Would this be correct?
Also with some help from here, I tried counting the number functions $f : A \to A$ so that $(f\circ f)(1) = 2$ and f is onto directly to which I got the answer as $7\cdot 1\cdot 7!$
I am not sure which would be correct.
Hint. If $f \circ f (1)=2$ then $f(1)=k$ and $f(k)=2$ for some $k\in \{2,3,4,5,6,7,8,9\}$ ($k=1$ is not allowed otherwise $f \circ f (1)=1$). Note that in order to be onto, $f$ should be bijective (hence $f(1)\not=2$ otherwise $f(1)=f(k)=2$ and $f$ is not injective).