# Can a sum of $n$ consecutive perfect squares be written as a sum of $n-1$ different perfect squares?

So, can $$\sum_{i=1}^n i^2$$ be written as a sum of $$n-1$$ different perfect squares? Surely if we are looking at this problem with small numbers, the answer is both yes and no. If we take $$n$$ to be 3, there can not be two different perfect squares numbers which satisfy the statement. If we take $$n$$ to be 4, we can see that $$3^{2}+4^{2}=5^{2}$$ which means that the statement is satisfied.

So, my truly question is: how can we find if a certain $$n$$ number is solution or not for this statement? (for example: Can $$\sum_{i=1}^{2015} i^2$$ be written as a sum of $$2014$$ different perfect squares?)

• I was pointing out the main idea of that sum. $1^{2}+2^{2}+3^{2}+4^{2} = 1^{2}+2^{2}+5^{2}$ – KroTeK Dec 11 '18 at 22:30

Let us replace 2015 by $$N$$. What you found, is that: if there exists $$1 \leq u such that $$u^2+v^2$$ is the square of some integer that is greater than $$N$$, then your statement holds. Now, let $$w=45^2+4^2=2041, u=2*45*4=360, v=45^2-4^2=2009.$$ Then $$w^2=u^2+v^2$$.
To generalize, let $$m$$ be the smallest integer such that $$m^2>N$$. Let $$k$$ be the smallest integet such that $$v=m^2-k^2 \leq N$$. Then, if $$0, $$u^2+v^2=(m^2+k^2)^2$$ and the statement holds.
Now, if $$v=0$$, then $$N < m^2-(m-1)^2=2m-1 < 2\sqrt{N}+1$$, thus $$N < 7$$.
Thus, if $$N > 6$$, $$k and $$2mk+k^2 \leq 3mk$$.
Now, $$k < 1+\sqrt{m^2-N} \leq 1+\sqrt{2\sqrt{N}+1} < 1+\sqrt{2m+1} \leq m/3$$ if $$m \geq 24$$ (corresponding to $$N \geq 23^2=529$$) so $$0 holds.
As a conclusion, if $$N$$ is large enough (at least $$529$$) your result holds.