Hello, I have a question that I not sure how to proceed on:

Let X be a nonempty set and let $\displaystyle f:X \rightarrow X$ be a function such that $\displaystyle (f \circ f) = f$.

Show that if f is onto then $\displaystyle f = 1^{}_{X}$.

I started by saying:

Suppose f is onto. Then for each $\displaystyle y \in X$ there exists at least one $\displaystyle x \in X$ such that $\displaystyle f(x) = y$.

And then I can't think what to do next. The previous question which was where I got to suppose f was one-to-one seemed much easier!