Solution (source code)

= Solution

Let $T_n=n(n+1)/2$, the $n$th <triangular number>. Pairing the terms of the <arithmetic progression> proves $\sum_{r=1}^n r=T_n$. We prove the cube identity by <mathematical induction>. For $n=1$ both sides equal one. If $\sum_{r=1}^n r^3=T_n^2$, then
$$
T_{n+1}^2-T_n^2=\frac{(n+1)^2}{4}\left[(n+2)^2-n^2\right]=(n+1)^3.
$$
Adding $(n+1)^3$ establishes the next case. Thus
$$
\boxed{\sum_{r=1}^n r^3=\left[\frac{n(n+1)}2\right]^2=\left(\sum_{r=1}^n r\right)^2}.
$$
Equivalently, the same displayed difference telescopes from $T_0=0$, providing a direct proof without induction.