$n^2+(n+1)^2+\cdots +(n+k)^2=(n+k+1)^2+\cdots +(n+2k)^2$

How many integers $n$ with $1\leq n \leq 2016$ are there such that the equation above is fulfilled for some positive integer $k$ ?

For example, with $n=3,k=1$ we have the familiar Pythagorean triple $3^2+4^2=5^2$ .

The answer is 31.

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

Using the identity $\displaystyle\sum_{m=1}^{N} m^{2} = \dfrac{N(N + 1)(2N + 1)}{6}$ the given equation can be written as

$\displaystyle\sum_{m=1}^{n+k} m^{2} - \sum_{m=1}^{n-1} m^{2} = \sum_{m=1}^{n + 2k} m^{2} - \sum_{m=1}^{n + k} m^{2} \Longrightarrow 2\sum_{m=1}^{n+k}m^{2} - \sum_{m=1}^{n-1} m^{2} = \sum_{m=1}^{n + 2k} m^{2}$

$\Longrightarrow \dfrac{2(n + k)(n + k + 1)(2n + 2k + 1)}{6} - \dfrac{(n - 1)(n)(2n - 1)}{6} = \dfrac{(n + 2k)(n + 2k + 1)(2n + 4k + 1)}{6}.$

Expanding and simplifying yields the quadratic $n^{2} - 2k^{2}n - k^{2}(1 + 2k) = 0$ , for which

$n = \dfrac{2k^{2} \pm \sqrt{4k^{4} + 4k^{2}(1 + 2k)}}{2} = k^{2} \pm k\sqrt{k^{2} + (1 + 2k)} = k^{2} \pm k\sqrt{(k + 1)^{2}} = k^{2} \pm k(k + 1).$

Now as we are looking for positive $n$ we need only consider the positive root

$n = k^{2} + k(k + 1) = k(2k + 1).$

Finally, as $31(2*31 + 1) = 1953 \lt 2016$ and $32(2*32 + 1) = 2080 \gt 2016$ we will find suitable values for $n$ for each integer $k$ such that $1 \le k \le 31$ , and so the desired answer is $\boxed{31}.$