Fixed power of elements of a group may fail to be a subgroup 
Looking for an example of a non abelian group $G$ such that for some $n\in \mathbb{N}$, the set $H= \{ g | g=x^n \text{ for some }x \in G \}$ fails to be a subgroup.

I tried with many non abelian groups with $n=2,3$ like $S_3$, $Q_8$ , but they are coming out to be a subgroup.
 A: I would consider dihedral group $$D_6=\langle r,s:r^3=s^2=1,sr=r^2s\rangle$$
Then $(D_6)^3=\{1,s,rs,r^2s\}$ which is clearly not a subgroup of $D_6$ since $|(D_6)^3|=4$ does not divide $|D_6|=6$.
A: A class of counterexamples . . .

Let $p$ be a prime with $p > 3$, and let $G=S_p$.

Let $m=(p-1)(p-1)!$, and let $H=\{x^m\mid x\in G\}$.

Claim:$\;H$ is not a subgroup of $G$.

Proof:

Let $e$ denote the identity element of $S_p$.

Let $S=\left\{x\in G\mid \text{ord}(x)\in \{1,p\}\right\}$.

Let $h\in H$.

Writing $h=x^{m}$, for some $x\in G$, we get
$$
h^p
=(x^m)^p
=x^{mp}
=x^{\bigl((p-1)(p-1)!\bigr)p}
=x^{(p-1)p!}
=\bigl(x^{p!}\bigr)^{p-1}
=e^{p-1}
=e
$$
hence $h\in S$.

Thus, we have $H\subseteq S$.

Let $x\in S$.

Since $\text{ord}(x)\in \{1,p\}$, we have $x^p=e$. 

By Wilson's Theorem, $(p-1)!\equiv -1\;(\text{mod}\;p)$, hence
\begin{align*}
&m=(p-1)(p-1)!\\[4pt]
\implies\;&m\equiv (-1)(-1)\;(\text{mod}\;p)\\[4pt]
\implies\;&m\equiv 1\;(\text{mod}\;p)\\[4pt]
\implies\;&p{\,\mid\,}(m-1)\\[4pt]
\implies\;&x^{m-1}=e\\[4pt]
\implies\;&x^m=x\\[4pt]
\implies\;&x\in H\\[4pt]
\end{align*}
Thus, we have $S\subseteq H$.

Since we have both inclusions, we get $H=S$.

Now let's count the number of elements of $S$ . . .


*

*$G$ has one element of order $1$, namely $e$.$\\[4pt]$

*The elements of $G$ of order $p$ are the $p$-cycles, for which the count is $(p-1)!$.


Letting $k=|H|$, we have $k=|H|=|S|=1+(p-1)!$, hence
\begin{align*}
p!&=p(p-1)!\\[4pt]
&=p(k-1)\\[4pt]
&=pk-p\\[4pt]
&\equiv -p\;(\text{mod}\;k)\\[4pt]
&\equiv k-p\;(\text{mod}\;k)\\[4pt]
&\equiv \bigl(1+(p-1)!\bigr)-p\;(\text{mod}\;k)\\[4pt]
&\equiv (p-1)!-(p-1)\;(\text{mod}\;k)\\[4pt]
&\not\equiv 0\;(\text{mod}\;k)\\[4pt]
\end{align*}
since $0 < (p-1)!-(p-1) < 1+ (p-1)! = k$.

Since $k$ is not a divisor of $p!$, it follows that $H$ is not a subgroup of $G$.
A: One of the simplest would be to take $S_3$ and then $H_n =\{ e,(12), (23), (13)\}$, which is not a subgroup of $S_3$ since its order is 4, and 4 does not divide 6.
