The following results are well-known:
(i) If $f(x)=x^2$ is a homomorphism from a (finite) group to itself, then the group must be abelian.
(ii) If $g(x)=x^3$ is a homomorphism from a finite group $G$ to itself, and if $(3,|G|)=1$, then $G$ is abelian.
Is there a generalization of $(ii)$ for some $n$ instead of $3$? Does it fail for some $n$ instead of $3$?
More precisely: is there other integer $n\neq 3$, such that following statement is true:
If $G$ is any finite group with $(|G|,n)=1$ and $f:G\rightarrow G$, $x\mapsto x^n$ is homomorphism, then $G$ is abelian