TITLE: Endomorphisms of forgetful functor $\mathbf{Grp}\to \mathbf{Set}$
QUESTION [11 upvotes]: It is well known endomorphisms of faithful functor form a monoid. I was trying to determine monoid of endomorphisms of forgetful functor $\mathbf{Grp} \to \mathbf{Set}$, and found it to be multiplicative monoid of $\mathbb{Z}$. Proof goes like this:

Let $U$ be the forgetful functor, and $\theta\colon U \to U$ a natural transformation. Consider infinite cyclic group $A=\left<a\right>$. We have $\theta_A(a) = a^k$ for some integer $k$. Now take arbitrary group $G$ and $g\in G$, and consider homomorphism $f\colon A\to G$ determined by $f(a) = g$. Clearly,
  $$
\theta_G\left(g\right) = \theta_G\left(f\left(a\right)\right) = 
\left(\theta_G \circ f\right)\left(a\right) =
\left(f\circ \theta_A\right)\left(a\right) = 
f\left(\theta_A(a)\right) = f(a^k)=\left(f(a)\right)^k = g^k
$$
  the only nontrivial equality true by naturality of $\theta$, and so endomorphisms of $U$ correspond to integers, composition given by multiplication.

Now, for the questions...

Is the above correct? It surely seems to be, but I find it kind of unsettling, especially since...
... the same reasoning seems to apply to $\mathbf{Ab}\to \mathbf{Set}$. Is the same indeed true for $\mathbf{Ab}$? I'd intuitively expect richer structure in the nonabelian case.
The role played by the cyclic group ($\mathbb{Z}$) seems worth further consideration. I know $\mathbb{Z}$ is a generator (separator) in $\mathbf{Grp}$, but it doesn't seem to immediately lead to any useful generalizations. Is there some connection between endomorphisms of forgetful functor and separators? Or some other related notion?
What about some "more abstract" ways to answer such questions? That is, instead of element chasing perhaps some variant of Yoneda lemma for suitably enriched categories?

REPLY [13 votes]: Your proof is correct. Here is a shorter proof using the Yoneda Lemma (actually you have proven the Yoneda Lemma in a special case, we do this all the time without knowing it):
The functor $U$ is representable by $\mathbb{Z}$ (since an element of a group is the same as a homomorphism from $\mathbb{Z}$). Hence, the Yoneda Lemma tells us
$$\mathrm{Hom}(U,U) \cong \mathrm{Hom}(\mathrm{Hom}(\mathbb{Z},-),U) \cong U(\mathbb{Z}),$$ the set of integers.
More generally, if $C$ is any variety of algebraic structures with forgetful functor $U : C \to \mathsf{Set}$, then $\mathrm{Hom}(U^n,U)$ corresponds to the underlying set of the free $C$-algebra on $n$ generators. You may imagine these as "universal $n$-ary operations". For example, for $C=\mathsf{Ring}$ and $n=2$ such an operation is $x^2 - xy +  y^2$.
More interesting things happen for non-algebraic categories. For example, consider the forgetful functor $U : \mathsf{FinGrp} \to \mathsf{Set}$ from the category of finite groups. Here, $U$ is not representable, but it is ind-representable: We have a canonical isomorphism
$$U \cong \varinjlim_n \,\mathrm{Hom}(\mathbb{Z}/n,-)$$
Therefore:
$$\mathrm{Hom}(U,U) \cong \varprojlim_n \,\mathrm{Hom}(\mathrm{Hom}(\mathbb{Z}/n,-),U) \cong \varprojlim_n U(\mathbb{Z}/n),$$
which is the underlying set of the pro-finite completion $\widehat{\mathbb{Z}}$. If $(\overline{z_n})_n$ is an element in $\widehat{\mathbb{Z}}$, the corresponding operation on finite groups maps an $n$-torsion element $g$ to $g^{z_n}$. This is well-defined precisely because we have $z_n \equiv z_m \bmod n$ for $n | m$. We get the same results when we work with the larger category of torsion groups.
In general, if you want to determine $\mathrm{Hom}(U,U)$ for any functor, try to write $U$ as a colimit of representable functors $\mathrm{Hom}(X_i,-)$ (this is always possible, though in general somewhat tautological), then $\mathrm{Hom}(U,U)$ is the limit of the $U(X_i)$.