Solution (source code)

= Solution

An <integer> square is divisible by four exactly when its base is even: an even base has square $4j^2$, while an odd base has square $(2j+1)^2\equiv1\pmod4$. Apply this observation to the <triangular number> $T_n$ obtained above. Since $n(n+1)$ is even,
$$
4\mid T_n^2\quad\Longleftrightarrow\quad 2\mid T_n\quad\Longleftrightarrow\quad4\mid n(n+1).
$$
Checking the four <residue classes> of $n$ modulo four, the products $n(n+1)$ have residues $0,2,2,0$, respectively. Therefore
$$
\boxed{4\mid\sum_{r=1}^n r^3\quad\Longleftrightarrow\quad n\equiv0\text{ or }3\pmod4}.
$$
The original PDF has two alternatives modulo four; the TeX transcription incorrectly turns the second alternative into a modulus-three expression.