If $m^2 = (a+1)^3 - a^3$, then $m$ is the sum of two squares.

Hint $ $ Times $\,4\,$ yields $\ 3\ (2a + 1)^2 = (2 m-1) (2 m + 1).\,$ The latter factors are coprime thus

$(1)\quad 2m - 1 = 3\ j^2,\,\ 2 m + 1 = k^2\ \Rightarrow\ k^2 - 3 j^2 = 2\ \Rightarrow\ k^2 \equiv -1\pmod{\! 3}\ \Rightarrow\!\Leftarrow$

$(2)\quad 2 m - 1 = \ j^2,\quad 2 m + 1 = 3 k^2 \Rightarrow\ {\rm odd}\ j = 2 i +\! 1\ \Rightarrow\ m\, = \dfrac{j^2+1}2 = (i+\!1)^2\! + i^2\ $

Remark $\ \ $ The above technique, exploiting the structure of coprime factors of powers in a UFD, is ubiquitous in number theory. Perhaps the simplest example is the parametrization of primitive Pythagorean triples $\rm\ x^2 + y^2 = z^2\:.$ The essence of the proof is: $\rm\ x+y\ i,\ x-y\ i\ $ are coprime factors of a square in a UFD, so they must themselves be squares (up to unit factors). Therefore $\rm\ x + y\ i\ =\ (m + n\ i)^2 =\ m^2 - n^2 + 2\: m\: n\ i\:.\: $ Similarly one can solve low degree cases of Fermat's Last Theorem by employing analogous factorizations over certain rings of algebraic integers. For example, Gauss showed there are no solutions for exponent 3 by working in the ring of integers of $\rm\ \mathbb Q(\sqrt{-3})\:,\: $ and Dirichlet did similarly for exponent 5 using $\rm\ \mathbb Q(\sqrt{5})\:.$ Later Kummer generalized these techniques to handle all regular prime exponents by working over rings of cyclotomic integers. For a nice exposition see Ribenboim: 13 lectures on Fermat's last theorem. Weil nicely summarizes the essence of these techniques in his Number Theory, Ch.IV,S.VI,p.335:

alt textalt text


The sequence of such $m$ is oeis.org/A001570 and there we learn that $m$ is a sum of consecutive squares, which is more than we need.

oeis.org/A001570 points to this note:

Victor Thebault, Consecutive Cubes with Difference a Square, The American Mathematical Monthly, Vol. 56, No. 3 (Mar., 1949), pp. 174-175.

There we learn that $m^2 = (a+1)^3 - a^3 = 3a^2+3a+1$ is equivalent to $(2m)^2-3(2a+1)^2=1$. Indeed, $(2a+1)^2=4a^2+4a+1$ and so $4m^2=3(2a+1)+1$. This is a Pell equation $u^2-3v^2=1$, with $u=2m$ and $v=2a+1$.

We also learn in that note that $m=(x+1)^2+x^2$ reduces to the same Pell equation $4r^2-3s^2=1$, but no details are given. These are left as an exercise. :-)