[proofplan]
We use the definition of the cyclic subgroup generated by $g$ as the set of all integer powers of $g$. If $g$ has finite order $n$, the [division algorithm](/theorems/725) reduces every power $g^k$ to one of $e,g,\dots,g^{n-1}$, and the equality criterion for powers shows these $n$ elements are distinct. If $g$ has infinite order, the same equality criterion shows that the map $k \mapsto g^k$ from $\mathbb{Z}$ into $\langle g \rangle$ is injective and surjective, so the generated subgroup is infinite.
[/proofplan]
custom_env
admin
[step:Reduce the generated subgroup to integer powers]
Let $e \in G$ denote the identity element of $G$. By definition of the subgroup generated by one element,
\begin{align*}
\langle g \rangle=\{g^k : k \in \mathbb{Z}\}.
\end{align*}
Thus computing $|\langle g \rangle|$ is the same as counting the distinct elements among the integer powers of $g$.
[/step]
custom_env
admin
[step:Count the distinct powers when $g$ has finite order]Assume $\operatorname{ord}(g)=n<\infty$. Then $n \in \mathbb{N}$ and $g^n=e$. Let
\begin{align*}
R=\{0,1,\dots,n-1\}\subset \mathbb{Z}.
\end{align*}
For every $k \in \mathbb{Z}$, the division algorithm gives integers $q \in \mathbb{Z}$ and $r \in R$ such that
\begin{align*}
k=qn+r.
\end{align*}
Using the laws of integer powers in a group and $g^n=e$, we obtain
\begin{align*}
g^k=g^{qn+r}=(g^n)^q g^r=e^q g^r=g^r.
\end{align*}
Therefore
\begin{align*}
\langle g \rangle=\{g^r : r \in R\}.
\end{align*}
It remains to show that these $n$ elements are distinct. Let $a,b \in R$ and suppose $g^a=g^b$. Since $\operatorname{ord}(g)=n<\infty$, [citetheorem:8238] gives
\begin{align*}
n \mid (a-b).
\end{align*}
Because $a,b \in \{0,1,\dots,n-1\}$, we have
\begin{align*}
-(n-1)\le a-b\le n-1.
\end{align*}
The only multiple of $n$ in this interval is $0$, so $a-b=0$, hence $a=b$. Thus $\{g^r:r \in R\}$ has exactly $n$ elements, and consequently
\begin{align*}
|\langle g \rangle|=n=\operatorname{ord}(g).
\end{align*}[/step]
custom_env
admin
[guided]Assume $\operatorname{ord}(g)=n<\infty$. This means $n$ is the least positive integer such that $g^n=e$. The central counting idea is that every exponent can be reduced modulo $n$, because multiplying the exponent by $n$ contributes a factor of $g^n=e$.
Define the set of allowed remainders by
\begin{align*}
R=\{0,1,\dots,n-1\}\subset \mathbb{Z}.
\end{align*}
For an arbitrary exponent $k \in \mathbb{Z}$, the division algorithm gives integers $q \in \mathbb{Z}$ and $r \in R$ satisfying
\begin{align*}
k=qn+r.
\end{align*}
Using the group laws for integer powers, together with $g^n=e$, we get
\begin{align*}
g^k=g^{qn+r}=(g^n)^q g^r=e^q g^r=g^r.
\end{align*}
So every element of $\langle g \rangle$ is one of the finitely many elements
\begin{align*}
e,g,g^2,\dots,g^{n-1}.
\end{align*}
Equivalently,
\begin{align*}
\langle g \rangle=\{g^r : r \in R\}.
\end{align*}
Now we must check that this list has no repetitions. Let $a,b \in R$ and suppose $g^a=g^b$. Since $g$ has finite order $n$, the finite-order part of [citetheorem:8238] applies and gives
\begin{align*}
g^a=g^b \iff n \mid (a-b).
\end{align*}
Hence $n \mid (a-b)$. But because $a$ and $b$ both lie between $0$ and $n-1$, their difference satisfies
\begin{align*}
-(n-1)\le a-b\le n-1.
\end{align*}
The only integer in this interval divisible by $n$ is $0$. Therefore $a-b=0$, so $a=b$.
Thus the elements $g^0,g^1,\dots,g^{n-1}$ are exactly the elements of $\langle g \rangle$, and they are pairwise distinct. There are $n$ of them, so
\begin{align*}
|\langle g \rangle|=n=\operatorname{ord}(g).
\end{align*}[/guided]
custom_env
admin
[step:Show the generated subgroup is infinite when $g$ has infinite order]
Assume $\operatorname{ord}(g)=\infty$. Define the map
\begin{align*}
\psi:\mathbb{Z}\to \langle g \rangle,\quad k\mapsto g^k.
\end{align*}
The map $\psi$ is surjective by the definition of $\langle g \rangle$. If $a,b \in \mathbb{Z}$ and $\psi(a)=\psi(b)$, then $g^a=g^b$. Since $\operatorname{ord}(g)=\infty$, [citetheorem:8238] gives $a=b$. Hence $\psi$ is injective. Therefore $\psi$ is a bijection from the infinite set $\mathbb{Z}$ onto $\langle g \rangle$, so $\langle g \rangle$ is infinite. Thus
\begin{align*}
|\langle g \rangle|=\infty=\operatorname{ord}(g).
\end{align*}
[/step]
custom_env
admin
[step:Combine the finite and infinite cases]
The finite-order case proves $|\langle g \rangle|=\operatorname{ord}(g)$ whenever $\operatorname{ord}(g)<\infty$. The infinite-order case proves that both sides are infinite whenever $\operatorname{ord}(g)=\infty$. These two cases exhaust all possibilities for $g$, so
\begin{align*}
|\langle g \rangle|=\operatorname{ord}(g)
\end{align*}
with the stated infinite interpretation.
[/step]