Solution (source code)

= Solution

Write $d=qr+s$ with $0\leq s<r$. Since $x^d=e\in H$ and $x^r\in H$,
$$
x^s=x^d(x^r)^{-q}\in H.
$$
The minimality of the positive integer $r$ forces $s=0$. Therefore
$$
\boxed{r\mid d}.
$$