Solution (source code)

= Solution

Define the <lower central series> by $\Gamma_1(G)=G$ and $\Gamma_{j+1}(G)=[\Gamma_j(G),G]$. Its terms are characteristic <normal subgroups> and form a descending chain. Define the <upper central series> by $Z_0(G)=1$ and
$$
Z_{i+1}(G)/Z_i(G)=Z\big(G/Z_i(G)\big).
$$
Equivalently, $Z_{i+1}(G)=\{x\in G:[x,G]\subseteq Z_i(G)\}$. These are characteristic <normal subgroups> in an ascending chain, and successive factors are central in the appropriate quotient.

For any length-$r$ <central series> $1=G_0\le\cdots\le G_r=G$, prove the two comparisons independently. Starting at $\Gamma_1(G)=G_r$, if $\Gamma_{r-i+1}(G)\le G_i$, then
$$
\Gamma_{r-i+2}(G)=[\Gamma_{r-i+1}(G),G]\le[G_i,G]\le G_{i-1}.
$$
Descending induction gives the lower containment. Starting at $G_0=Z_0(G)=1$, if $G_{i-1}\le Z_{i-1}(G)$, then $[G_i,G]\le G_{i-1}\le Z_{i-1}(G)$, which by definition gives $G_i\le Z_i(G)$. Thus the <central-series comparison theorem> yields
$$
\boxed{\Gamma_{r-i+1}(G)\le G_i\le Z_i(G)\quad(0\le i\le r).}
$$
In particular, a <nilpotent group> satisfies $\Gamma_{r+1}(G)=1$ and $Z_r(G)=G$.

Conversely, if $\Gamma_n(G)=1$, reverse the finite lower chain to obtain $1=\Gamma_n\le\Gamma_{n-1}\le\cdots\le\Gamma_1=G$. The defining commutator recurrence makes it a <central series>. If $Z_n(G)=G$, the finite upper chain is already a <central series>. This proves
$$
\boxed{G\text{ nilpotent}\ \Longleftrightarrow\ \Gamma_n(G)=1\text{ for some }n\ \Longleftrightarrow\ Z_n(G)=G\text{ for some }n.}
$$
Finally, for an integer $c>0$, termination at $\Gamma_{c+1}=1$ gives a <central series> of length $c$ and hence $Z_c=G$ by the comparison. Conversely, $Z_c=G$ gives a <central series> of length $c$ and hence $\Gamma_{c+1}=1$. Therefore
$$
\boxed{\Gamma_{c+1}(G)=1\quad\Longleftrightarrow\quad Z_c(G)=G.}
$$
Repeated terms cause no problem; the least such $c$ for a nontrivial group is its <nilpotency class>.