Solution (source code)

= Solution

Among the $n+1$ right cosets
$$
H,Hx,Hx^2,\ldots,Hx^n
$$
two must coincide because $[G:H]=n$. If $Hx^i=Hx^j$ with $0\leq i<j\leq n$, right multiplication by $x^{-i}$ gives $H=Hx^{j-i}$, so
$$
x^{j-i}\in H,
\qquad
0<j-i\leq n.
$$

The least such exponent need not divide $n$. For example, take $G=S_3$, $H=\langle(12)\rangle$, and $x=(13)$. Then $[G:H]=3$, while $x\notin H$ and $x^2=e\in H$, so the least exponent is two, which does not divide three.