Solution (source code)

= Solution

Let $d=\operatorname{ord}(g)$. The powers
$$
\langle g\rangle=\{e,g,\ldots,g^{d-1}\}
$$
are distinct: equality of two with exponents between $0$ and $d-1$ would give a smaller positive power equal to $e$. Reducing exponents modulo $d$ proves closure and supplies inverses, so this is a <cyclic subgroup> of <group order> $d$. <Lagrange's theorem> now gives
$$
\boxed{\operatorname{ord}(g)=|\langle g\rangle|\mid |G|.}
$$