We study the Diophantine problem of determining for which positive integers \(M\) the sum of \(M\) consecutive squares beginning at \(a^{2}\) can itself be a square, namely \[\sum\limits_{i=0}^{M-1}(a+i)^{2}=s^{2}.\] Using the necessary conditions established by Beeckmans, we derive sharper congruence restrictions on the parameter \(M\). In particular, we prove that no solution exists when \(M\equiv5,6,7,8\) or \(10\left(\text{mod}\,12\right)\). For the remaining congruence classes \(M\equiv0,1,2,4,9\) or \(11\left(\text{mod}\,12\right)\), we obtain refined necessary conditions, namely \(M\equiv0\) or \(24\left(\text{mod}\,72\right)\); \(M\equiv1,2\) or \(16\left(\text{mod}\,24\right)\); \(M\equiv9\) or \(33\left(\text{mod}\,72\right)\); or \(M\equiv11\left(\text{mod}\,12\right)\), together with the corresponding congruence restrictions on \(a\) and \(s\). These classes should be interpreted only as necessary compatibility conditions; they do not, on their own, establish the existence of solutions. The remaining residue class \(M\equiv3\left(\text{mod}\,12\right)\) is examined separately by means of a recursive residue-class sieve that yields computational evidence against solvability, although no complete symbolic exclusion is claimed. Finally, when \(M\) is itself a square and a solution exists, we show that necessarily \(M\equiv1\left(\text{mod}\,24\right)\) and \(\left(M-1\right)/24\) is a generalized pentagonal number.
Lucas stated in 1873 [1] (see also [2]) that \(\sum n^{2}\) is a square only for \(n=1\) and \(24\). He proposed further in 1875 [3] the well-known cannonball problem, namely to find a square number of cannonballs stacked in a square pyramid. This problem can clearly be written as a Diophantine equation \(\sum\limits_{i=1}^{M}\left(i^{2}\right)=M\left(M+1\right)\left(2M+1\right)/6=s^{2}\). The only solutions are \(s^{2}=1\) and \(4900\), which correspond to the sum of the first \(M\) square integers for \(M=1\) and \(M=24\). This was proved in part by Moret-Blanc [4] and Lucas [5], and was later proved in full by Watson [6] (with elementary proofs in most cases and using elliptic functions for one case), Ljunggren [7], Ma [8] and Anglin [9] (both with only elementary proofs).
A more general problem is to determine all values of \(a\) for which the sum of \(M\) consecutive squares beginning at \(a^{2}\geq1\) is itself a square \(s^{2}\). Several authors have investigated this question from different perspectives. Alfred [10] established a number of necessary conditions on \(M\) (using the notation adopted here) and identified the admissible values \(M=2,11,23,24,26,\ldots\) up to \(M=500\), while leaving unresolved the cases \(M=107,193,227,275,457\). Philipp [11] later showed that solutions exist for \(M=107,193,457\) but not for \(M=227,275\), and proved that the number of solutions is finite or infinite according to whether \(M\) is, or is not, a square. Laub [12] proved that the set of integers \(M\) for which a sum of \(M\) consecutive squares is again a square is infinite, but of density zero. Beeckmans [13] established eight necessary conditions on \(M\) and listed all values \(M<1000\) together with the smallest corresponding value of \(a>0\), while noting two cases, namely \(M=25\) and \(M=842\), that satisfy these necessary conditions without yielding a solution.
The purpose of the present paper is to sharpen Beeckmans’ congruence-based restrictions on the parameter \(M\). We prove that \(M\) cannot be congruent modulo \(12\) to \(5,6,7,8\), or \(10\). For the remaining classes \(M\equiv0,1,2,4,9\) or \(11\left(\text{mod}\,12\right)\), we refine the admissible residue classes and derive the necessary conditions \(M\equiv0\) or \(24\left(\text{mod}\,72\right)\); \(M\equiv1,2\) or \(16\left(\text{mod}\,24\right)\); \(M\equiv9\) or \(33\left(\text{mod}\,72\right)\); or \(M\equiv11\left(\text{mod}\,12\right)\), together with the corresponding congruence restrictions on \(a\) and \(s\). These results are purely necessary conditions: they identify residue classes compatible with a solution, but they do not by themselves prove that solutions exist in every such class. The remaining case \(M\equiv3\left(\text{mod}\,12\right)\) is treated separately by means of a recursive residue-class sieve that yields computational evidence against solvability, although no complete symbolic proof is claimed here. We also show that, if \(M\) is itself a square and a solution exists, then necessarily \(M\equiv1\left(\text{mod}\,24\right)\) and \(\left(M-1\right)/24\) is a generalized pentagonal number.
Throughout the paper, the notation \(A\left(\text{mod}\,B\right)\equiv C\) is used interchangeably with \(A\equiv C\left(\text{mod}\,B\right)\). Likewise, the implication \(A\equiv C\left(\text{mod}\,B\right)\Rightarrow A=Bk+C\) means that, if \(A\equiv C\left(\text{mod}\,B\right)\), then there exists \(k\in\mathbb{Z}^{+}\) such that \(A=Bk+C\). By convention, \(\sum\limits_{j=inf}^{sup} f\left(j\right)=0\) whenever \(sup<inf\).
We begin by identifying several residue classes modulo \(12\) that are impossible for \(M\). The proof makes use of a number of auxiliary integer sequences, collected in the following lemma.
Lemma 1. For \(n,\alpha\in\mathbb{Z}^{+}\) and \(i,\delta\in\mathbb{Z}^{*}\):
\(\left[\left(3^{2\left(n-1\right)}-1\right)/4\right]\)
and \(\left[\left(3^{2n-1}+1\right)/4\right]\in\mathbb{Z}^{*}\),
\(\forall\; n\); furthermore, \(\left[\left(3^{2n-1}+1\right)/4\right]\equiv1\)
or \(3\left(\text{mod}\,4\right)\) for
\(n\equiv1\) or \(0\left(\text{mod}\,2\right)\);
\(\left[\left(3^{2n-1}-2^{\alpha}+1\right)/12\right]=\left[2\left(\sum\limits_{i=0}^{n-2}3^{2i}\right)-\left(2^{\alpha-2}-1\right)/3\right]\in\mathbb{Z}^{+}\),
\(\forall n\geq2\), \(\forall\alpha\equiv0\left(\text{mod}\,2\right)\),
and \(\left[\left(3^{2n-1}-5\times2^{\alpha}+1\right)/12\right]=\left[2\left(\sum\limits_{i=0}^{n-2}3^{2i}\right)-\left(5\times2^{\alpha-2}-1\right)/3\right]\in\mathbb{Z}^{+},\)
\(\forall n\geq2\), \(\forall\alpha\equiv1\left(\text{mod}\,2\right),\alpha>1\);
\(\left[\left(3^{2n-1}\times13+1\right)/16\right]\in\mathbb{Z}^{+}\),
\(\forall
n\equiv0\left(\text{mod}\,2\right)\); \(\left[\left(3^{2n-1}\times37+1\right)/16\right]\in\mathbb{Z}^{+}\),
\(\forall
n\equiv1\left(\text{mod}2\right)\); \(\left[\left(3^{2n-1}\times25-11\right)/16\right]\in\mathbb{Z}^{+}\),
\(\forall
n\equiv1\left(\text{mod}2\right)\);
\(\left[\left(3^{2n-1}\left(13+24\delta\right)-23\right)/32\right]\in\mathbb{Z}^{+}\) for \(\delta=0\), \(\forall n\equiv3\left(\text{mod}\,4\right)\); for \(\delta=1\), \(\forall n\equiv0\left(\text{mod} 4\right)\); for \(\delta=2\), \(\forall n\equiv1\left(\text{mod}4\right)\); and for \(\delta=3\), \(\forall n\equiv2\left(\text{mod}\,4\right)\).
Proof. For \(n,n^{\prime},\alpha\in\mathbb{Z}^{+}\) and \(i,\delta\in\mathbb{Z}^{*}\);
immediate as \(\forall n\), \(3^{2\left(n-1\right)}\equiv1\left(\text{mod}\,8\right)\) and \(3^{2n-1}\equiv3\left(\text{mod}\,4\right)\) (1). Furthermore,
if \(n\equiv1\left(\text{mod}\,2\right)\) \(\Rightarrow\) \(n=2n^{\prime}+1\), assume that \(\left[\left(3^{2n-1}+1\right)/4\right]\equiv1\left(\text{mod}\,4\right)\), then \(\left(3^{2n-1}+1\right)\equiv4\left(\text{mod}\,16\right)\) \(\Rightarrow\) \(\left(3\left(3^{4n^{\prime}}-1\right)\right)\equiv0\left(\text{mod}\,16\right)\), which is the case as \(\forall n^{\prime}\), \(\left(3^{2n^{\prime}}+1\right)\equiv0\left(\text{mod}\,2\right)\) and \(\left(3^{2n^{\prime}}-1\right)\equiv0\left(\text{mod}\,8\right)\);
if now \(n\equiv0\left(\text{mod}\,2\right)\) \(\Rightarrow\) \(n=2n^{\prime}\), assume that \(\left[\left(3^{2n-1}+1\right)/4\right]\equiv3\left(\text{mod}\,4\right)\), then \(\left(3^{2n-1}+1\right)\equiv12\left(\text{mod}\,16\right)\) \(\Rightarrow\) \(\left(3\left(3^{4n^{\prime}-2}-1\right)\right)\equiv8\left(\text{mod}\,16\right)\), which is the case as \(\forall n^{\prime}\), \(\left(3^{2n^{\prime}-1}+1\right)\equiv0\left(\text{mod}\,4\right)\) and \(\left(3^{2n^{\prime}-1}-1\right)\equiv0\left(\text{mod}\,2\right)\).
As \(\forall n\geq2\), \(\left[\left(3^{2\left(n-1\right)}-1\right)/8\right]=\sum\limits_{i=0}^{n-2}3^{2i}\) (2), then: \[\begin{aligned} \left(\frac{3^{2n-1}-2^{\alpha}+1}{12}\right) & = & \left(\frac{3^{2n-1}-3}{12}\right)-\left(\frac{2^{\alpha}-4}{12}\right)\nonumber \\ & = & 2\left(\sum\limits_{i=0}^{n-2}3^{2i}\right)-\left(\frac{2^{\alpha-2}-1}{3}\right)\in\mathbb{Z}^{+},\label{eq:7} \end{aligned} \tag{1}\] as \(\forall\alpha\equiv0\left(\text{mod}\,2\right)\), \(2^{\alpha-2}\equiv1\left(\text{mod}\,3\right)\), and \[\begin{aligned} \left(\frac{3^{2n-1}-5\times2^{\alpha}+1}{12}\right) & = & \left(\frac{3^{2n-1}-3}{12}\right)-\left(\frac{5\times2^{\alpha}-4}{12}\right)\nonumber \\ & = & 2\left(\sum\limits_{i=0}^{n-2}3^{2i}\right)-\left(\frac{5\times2^{\alpha-2}-1}{3}\right)\in\mathbb{Z}^{+},\label{eq:8} \end{aligned} \tag{2}\] as \(\forall\alpha\equiv1\left(\text{mod}\,2\right),\alpha>1\), \(2^{\alpha-2}\equiv2\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(\left(5\times2^{\alpha-2}\right)\equiv1\left(\text{mod}\,3\right)\).
Immediate as \(\forall n\equiv0\left(\text{mod}\,2\right)\), \(3^{2n}\equiv1\left(\text{mod}\,16\right)\) and \(\forall n\equiv1\left(\text{mod}\,2\right)\), \(3^{2n-1}\equiv3\left(\text{mod}\,16\right)\) \(\Rightarrow\) \(\left(3^{2n-1}\times5\right)\equiv15\left(\text{mod}\,16\right)\), yielding:
\(\left(3^{2n-1}\times13+1\right)\left(\text{mod}\,16\right)\equiv\left(-3^{2n}+1\right)\left(\text{mod}\,16\right)\equiv0\);
\(\left(3^{2n-1}\times37+1\right)\left(\text{mod}\,16\right)\equiv\left(3^{2n-1}\times5+1\right)\left(\text{mod}\,16\right)\equiv0\);
\(\left(3^{2n-1}\times25-11\right)\left(\text{mod}\,16\right)\equiv\)\(\left(5\left(3^{2n-1}\times5+1\right)\right)\left(\text{mod}\,16\right)\equiv0\).
As \(\left(3^{2n-1}\left(13+24\delta\right)-23\right)\left(\text{mod}\,32\right)\equiv3^{2}\left(3^{2n-3}\left(13+24\delta\right)+1\right)\left(\text{mod}\,32\right)\),
\(\delta=0\): \(3^{2}\left(3^{2n-3}\times13+1\right)\left(\text{mod}\,32\right)\equiv0\) as \(\forall n\equiv3\left(\text{mod}\,4\right)\), \(3^{2n-3}\equiv27\left(\text{mod}\,32\right)\) \(\Rightarrow\) \(\left(3^{2n-3}\times13\right)\equiv31\left(\text{mod}\,32\right)\);
\(\delta=1\): \(3^{2}\left(3^{2n-3}\times37+1\right)\left(\text{mod}\,32\right)\equiv3^{2}\left(3^{2n-3}\times5+1\right)\left(\text{mod}\,32\right)\equiv0\) as \(\forall n\equiv0\left(\text{mod}\,4\right)\), \(3^{2n-3}\equiv19\left(\text{mod}\,32\right)\) \(\Rightarrow\) \(\left(3^{2n-3}\times5\right)\equiv31\left(\text{mod}\,32\right)\);
\(\delta=2\): \(3^{2}\left(3^{2n-3}\times61+1\right)\left(\text{mod}\,32\right)\equiv3^{2}\left(-3^{2n-2}+1\right)\left(\text{mod}\,32\right)\equiv0\) as \(\forall n\equiv1\left(\text{mod}\,4\right)\), \(3^{2n-2}\equiv1\left(\text{mod}\,32\right)\);
\(\delta=3\): \(3^{2}\left(3^{2n-3}\times85+1\right)\left(\text{mod}\,32\right)\equiv3^{2}\left(3^{2n-2}\times7+1\right)\left(\text{mod}\,32\right)\equiv0\) as \(\forall n\equiv2\left(\text{mod}\,4\right)\), \(3^{2n-2}\equiv9\left(\text{mod}\,32\right)\) \(\Rightarrow\) \(\left(3^{2n-2}\times7\right)\equiv31\left(\text{mod}\,32\right)\).
◻
We now combine the preceding lemma with the eight necessary conditions established by Beeckmans [13] to derive the following theorem on the admissible values of \(M\). for (3) to hold, that can be summarized as follows, with the notations of this paper and where \(e,\alpha\in\mathbb{Z}^{+}\):
1) If \(M\equiv0\left(\text{mod}\,2^{e}\right)\) or if \(M\equiv0\left(\text{mod}\,3^{e}\right)\) or if \(M\equiv-1\left(\text{mod}\,3^{e}\right)\), then \(e\equiv1\left(\text{mod}\,2\right)\); (C1.1, C1.2, C1.3).
2) If \(p>3\) is prime, \(M\equiv0\left(\text{mod}\,p^{e}\right)\), \(e\equiv1\left(\text{mod}\,2\right)\), then \(p\equiv\pm1\left(\text{mod}\,12\right)\); (C2).
3) If \(p\equiv3\left(\text{mod}\,4\right),p>3\) is prime, \(M\equiv-1\left(\text{mod}\,p^{e}\right)\), then \(e\equiv0\left(\text{mod}\,2\right)\); (C3).
4) \(M\neq3\left(\text{mod}\,9\right)\), \(M\neq\left(2^{\alpha}-1\right)\left(\text{mod}\,2^{\alpha+2}\right)\) and \(M\neq2^{\alpha}\left(\text{mod}\,2^{\alpha+2}\right)\) \(\forall\alpha\geq2\). (C4.1, C4.2, C4.3).
Theorem 1. For \(M>1,\in\mathbb{Z}^{+}\), the sum of squares of \(M\) consecutive integers cannot be an integer square if \(M\equiv5,6,7,8\) or \(10\left(\text{mod}\,12\right)\).
The demonstration is made in the order \(M\equiv5,7,6,10\) and \(8\left(\text{mod}\,12\right)\).
Proof. For \(M,\mu,i,k,K,m,m_{i},e_{i},p_{i},n,\alpha,\beta,\epsilon,\gamma_{n},\kappa,\xi,A,B\in\mathbb{Z}^{+},\eta\in\mathbb{Z}\), \(M>1\), \(3\leq\mu\leq10\), let \(M\equiv\mu\left(\text{mod}\,12\right)\) \(\Rightarrow\) \(M=12m+\mu\).
For \(\mu=5\) or \(7\), \(M=12m+5\) or \(12m+7\), let \(\prod\left(p_{i}^{e_{i}}\right)\) be the decomposition of \(M\) in \(i\) prime factors \(p_{i}\), with \(\prod\left(p_{i}^{e_{i}}\right)\equiv5\) or \(7\left(\text{mod}\,12\right)\). Then one of the prime factors is \(p_{j}\equiv5\) or \(7\left(\text{mod}\,12\right)\) with an exponent \(e_{j}\equiv1\left(\text{mod}\,2\right)\) (the remaining co-factor is \(\left(\prod\left(p_{i}^{e_{i}}\right)/p_{j}^{e_{j}}\right)\equiv1\) or \(11\left(\text{mod}\,12\right)\)), contradicting (C2) and these values of \(M\) must be rejected.
For \(\mu=6\) or \(10\), \(M=12m+6\) or \(12m+10\), \(M+1=4\left(3m+1\right)+3\) or \(4\left(3m+2\right)+3\), i.e. in both cases \(\left(M+1\right)\equiv3\left(\text{mod}\,4\right)\). Let \(\prod\left(p_{i}^{e_{i}}\right)\) be the decomposition of \(\left(M+1\right)\) in \(i\) prime factors \(p_{i}\). Then one of the prime factors is \(p_{j}\equiv3\left(\text{mod}\,4\right)\) with an exponent \(e_{j}\equiv1\left(\text{mod}\,2\right)\) (the remaining co-factor being \(\left(\prod\left(p_{i}^{e_{i}}\right)/p_{j}^{e_{j}}\right)\equiv1\left(\text{mod}\,4\right)\)), contradicting (C3).
For \(\mu=8\), \(M=12m+8\) and \(M+1=3\left(4m+3\right)\), cases appear cyclically with values of \(\left(M+1\right)\) having either a factor \(3\) with an even exponent or a factor \(f\) such as \(f\equiv3\left(\text{mod}\,4\right)\). Indeed, let first \(m\neq0\left(\text{mod}\,3\right)\) and second \(m\equiv0\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(m=3m_{1}\). Let then first \(m_{1}\neq2\left(\text{mod}\,3\right)\) and second \(m_{1}\equiv2\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(m_{1}=3m_{2}+2\). Let then again first \(m_{2}\neq0\left(\text{mod}\,3\right)\) and second \(m_{2}\equiv0\left(\text{mod}\,3\right)\) \(\Rightarrow\)\(m_{2}=3m_{3}\), and so on, yielding:
\(M+1=3\left(4m+3\right)\),
\(\Rightarrow\) if \(m\neq0\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(\left(M+1\right)\equiv3\left(\text{mod}\,4\right)\),
\(\Rightarrow\) if \(m\equiv0\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(m=3m_{1}\) \(\Rightarrow\) \(M+1=3^{2}\left(4m_{1}+1\right)\),
\(\Rightarrow\) if \(m_{1}\neq2\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(\left(M+1\right)\equiv0\left(\text{mod}\,3^{2}\right)\),
\(\Rightarrow\) if \(m_{1}\equiv2\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(m_{1}=3m_{2}+2\) \(\Rightarrow\) \(M+1=3^{3}\left(4m_{2}+3\right)\),
\(\Rightarrow\) if \(m_{2}\neq0\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(\left(M+1\right)\equiv3\left(\text{mod}\,4\right)\),
\(\Rightarrow\) if \(m_{2}\equiv0\left(\text{mod}\,3\right)\) \(\Rightarrow\) \(m_{2}=3m_{3}\) \(\Rightarrow\) \(M+1=3^{4}\left(4m_{3}+1\right)\),
and so on. After \(n\) iterations, \(\exists m_{n}\in\mathbb{Z}^{+}\) such as either \(M+1=3^{n}\left(4m_{n}+1\right)\) if \(n\equiv0\left(\text{mod}\,2\right)\), contradicting (C1.3), or \(M+1=3^{n}\left(4m_{n}+3\right)\) if \(n\equiv1\left(\text{mod}\,2\right)\). Then let \(\prod\left(p_{i}^{e_{i}}\right)\) be the decomposition of \(\left[\left(M+1\right)/3^{n}\right]\) in \(i\) prime factors \(p_{i}\), with \(\prod\left(p_{i}^{e_{i}}\right)\equiv3\left(\text{mod}\,4\right)\). Then one of the prime factors is \(p_{j}\equiv3\left(\text{mod}\,4\right)\) with an exponent \(e_{j}\) such as \(e_{j}\equiv1\left(\text{mod}\,2\right)\) (the remaining co-factor being such as \(\left(\prod\left(p_{i}^{e_{i}}\right)/p_{j}^{e_{j}}\right)\equiv1\left(\text{mod}\,4\right)\)), contradicting (C3). Therefore, these values of \(M\) must be rejected in both cases.
◻
Remark 1. The class \(M\equiv3\pmod{12}\) leads to a substantially more delicate \(2\)-adic splitting analysis. The computations carried out for this case yield a recursive residue-class sieve, based on repeated applications of Beeckmans’ conditions (C4.2) and (C3), which eliminates all residue classes examined in that branch. These results provide strong computational evidence against solvability when \(M\equiv3\pmod{12}\). However, since a complete symbolic exclusion argument has not been established here, no general impossibility theorem is claimed for this residue class, and this case is not used in any subsequent result.
The next theorem gives refined necessary conditions in the congruence classes \(\mu=0,1,2,4,9\) and \(11\).
| \(\mu\) | \(M\equiv\) | \(m\equiv\) | \(a\equiv\) | \(s\equiv\) |
|---|---|---|---|---|
| \(0\) | \(0\left(\text{mod}\,72\right)\) | \(0\left(\text{mod}\,6\right)\) | \(\forall\) | \(0\left(\text{mod}\,6\right)\) |
| \(24\left(\text{mod}\,72\right)\) | \(2\left(\text{mod}\,6\right)\) | \(\forall\) | \(2\) or \(4\left(\text{mod}\,6\right)\) | |
| \(1\) | \(1\left(\text{mod}\,24\right)\) | \(0\left(\text{mod}\,6\right)\) | \(\forall\) | \(\forall\) |
| \(2\left(\text{mod}\,6\right)\) | \(0\left(\text{mod}\,6\right)\) | \(2\) or \(4\left(\text{mod}\,6\right)\) | ||
| \(3\left(\text{mod}\,6\right)\) | \(1\) or \(5\left(\text{mod}\,6\right)\) | |||
| \(4\left(\text{mod}\,6\right)\) | \(1\left(\text{mod}\,2\right)\) | \(3\left(\text{mod}\,6\right)\) | ||
| \(0\left(\text{mod}\,2\right)\) | \(0\left(\text{mod}\,6\right)\) | |||
| \(2\) | \(2\left(\text{mod}\,24\right)\) | \(0\left(\text{mod}\,6\right)\) | \(0,2\left(\text{mod}\,3\right)\) | \(1\) or \(5\left(\text{mod}\,6\right)\) |
| \(2\left(\text{mod}\,6\right)\) | \(1\left(\text{mod}\,3\right)\) | \(3\left(\text{mod}\,6\right)\) | ||
| \(4\left(\text{mod}\,6\right)\) | \(\forall\) | \(1\left(\text{mod}\,2\right)\) | ||
| \(4\) | \(16\left(\text{mod}\,24\right)\) | \(1\left(\text{mod}\,6\right)\) | \(0\left(\text{mod}\,3\right)\) | \(2\) or \(4\left(\text{mod}\,6\right)\) |
| \(3\left(\text{mod}\,6\right)\) | \(1,2\left(\text{mod}\,3\right)\) | \(0\left(\text{mod}\,6\right)\) | ||
| \(5\left(\text{mod}\,6\right)\) | \(\forall\) | \(0\left(\text{mod}\,2\right)\) | ||
| \(9\) | \(9\left(\text{mod}\,72\right)\) | \(0\left(\text{mod}\,6\right)\) | \(0\left(\text{mod}\,2\right)\) | \(0\left(\text{mod}\,6\right)\) |
| \(1\left(\text{mod}\,2\right)\) | \(3\left(\text{mod}\,6\right)\) | |||
| \(33\left(\text{mod}\,72\right)\) | \(2\left(\text{mod}\,6\right)\) | \(0\left(\text{mod}\,2\right)\) | \(2\) or \(4\left(\text{mod}\,6\right)\) | |
| \(1\left(\text{mod}\,2\right)\) | \(1\) or \(5\left(\text{mod}\,6\right)\) | |||
| \(11\) | \(11\left(\text{mod}\,12\right)\) | \(0\left(\text{mod}\,6\right)\) | \(0,2\left(\text{mod}\,6\right)\) | \(1\) or \(5\left(\text{mod}\,6\right)\) |
| \(1\left(\text{mod}\,6\right)\) | \(1\left(\text{mod}\,6\right)\) | \(2\) or \(4\left(\text{mod}\,6\right)\) | ||
| \(3,5\left(\text{mod}\,6\right)\) | \(0\left(\text{mod}\,6\right)\) | |||
| \(2\left(\text{mod}\,6\right)\) | \(4\left(\text{mod}\,6\right)\) | \(3\left(\text{mod}\,6\right)\) | ||
| \(3\left(\text{mod}\,6\right)\) | \(3,5\left(\text{mod}\,6\right)\) | \(2\) or \(4\left(\text{mod}\,6\right)\) | ||
| \(4\left(\text{mod}\,6\right)\) | \(0,2\left(\text{mod}\,6\right)\) | \(3\left(\text{mod}\,6\right)\) | ||
| \(4\left(\text{mod}\,6\right)\) | \(1\) or \(5\left(\text{mod}\,6\right)\) | |||
| \(5\left(\text{mod}\,6\right)\) | \(1\left(\text{mod}\,6\right)\) | \(0\left(\text{mod}\,6\right)\) |
Theorem 2. Let \(M>1\), \(a,s\in\mathbb{Z}^{+}\), and suppose that \(\sum\limits_{i=0}^{M-1}\left(a+i\right)^{2}=s^{2}\). If \(M\equiv0,1,2,4,9\) or \(11\left(\text{mod}\,12\right)\), then the following refined congruence restrictions are necessary:
if \(M\equiv0\left(\text{mod}\,12\right)\), then \(M\equiv0\) or \(24\left(\text{mod}\,72\right)\);
if \(M\equiv1\left(\text{mod}\,12\right)\), then \(M\equiv1\left(\text{mod}\,24\right)\);
if \(M\equiv2\left(\text{mod}\,12\right)\), then \(M\equiv2\left(\text{mod}\,24\right)\);
if \(M\equiv4\left(\text{mod}\,12\right)\), then \(M\equiv16\left(\text{mod}\,24\right)\);
if \(M\equiv9\left(\text{mod}\,12\right)\), then \(M\equiv9\) or \(33\left(\text{mod}\,72\right)\);
and the corresponding necessary congruent values of \(a\) and \(s\) are given in Table 1.
Proof. For \(M>1,m,a,s\in\mathbb{Z}^{+}\) and \(\mu,i\in\mathbb{Z}^{*}\), \(0\leq\mu\leq11\), let \(M\equiv\mu\left(\text{mod}\,12\right)\) \(\Rightarrow\) \(M=12m+\mu\). Expressing the sum of \(M\) consecutive integer squares starting from \(a^{2}\) equal to an integer square \(s^{2}\) as
\[\sum\limits_{i=0}^{M-1}\left(a+i\right)^{2}=M\left[\left(a+\frac{M-1}{2}\right)^{2}+\frac{M^{2}-1}{12}\right]=s^{2},\label{eq:53-3} \tag{3}\] and replacing \(M\) by \(12m+\mu\) in (3) yields
\[\left(12m+\mu\right)\left[a^{2}+a\left(12m+\mu-1\right)+48m^{2}+2m\left(4\mu-3\right)+\frac{2\mu^{2}-3\mu+1}{6}\right]=s^{2}.\label{eq:53-2} \tag{4}\] Recalling that integer squares are congruent to either \(0,1,4\) or \(9\left(\text{mod}\,12\right)\), replacing the values of \(\mu=0,1,2,4,9,11\) in (4) and reducing \(\left(\text{mod}\,12\right)\) yield:
For \(\mu=0\), \(\left(2m\left(6a^{2}-6a+1\right)-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\).
As \(\forall a\), \(\left(6a^{2}-6a\right)\equiv0\left(\text{mod}\,12\right)\), it yields \(\left(2m-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\) \(\Rightarrow\) \(s\equiv0\left(\text{mod}\,6\right)\) for \(m\equiv0\left(\text{mod}\,6\right)\) and \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\) for \(m\equiv2\left(\text{mod}\,6\right)\).
Therefore, \(M\equiv0\left(\text{mod}\,72\right)\) with \(s\equiv0\left(\text{mod}\,6\right)\) or \(M\equiv24\left(\text{mod}\,72\right)\) with \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\) and \(a\) can take any value.
For \(\mu=1\), \(\left(a^{2}+2m-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\).
For \(a^{2}\equiv\left\{ 0,1,4,9\right\} \left(\text{mod}\,12\right)\), \(2m\equiv\left\{ \left(0\,{or}\,4\right),\left(0\,{or}\,8\right),\left(0\,{or}\,8\right),\left(0\,{or}\,4\right)\right\} \left(\text{mod}\,12\right)\) respectively for \(s^{2}\equiv\left\{ \left(0\,{or}\,4\right),\left(1\,{or}\,9\right),\left(4\,{or}\,0\right),\left(9\,{or}\,1\right)\right\} \left(\text{mod}\,12\right)\), yielding
\(m\equiv0\left(\text{mod}\,2\right)\) and \(M\equiv1\left(\text{mod}\,24\right)\). Furthermore,
if \(m\equiv0\left(\text{mod}\,6\right)\), \(a\) and \(s\) can take any values;
if \(m\equiv2\left(\text{mod}\,6\right)\), either \(a\equiv0\left(\text{mod}\,6\right)\) and \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\), or \(a\equiv3\left(\text{mod}\,6\right)\) and \(s\equiv1\) or \(5\left(\text{mod}\,6\right)\); and
if \(m\equiv4\left(\text{mod}\,6\right)\), either \(a\equiv1\left(\text{mod}\,2\right)\) and \(s\equiv3\left(\text{mod}\,6\right)\), or \(a\equiv0\left(\text{mod}\,2\right)\) and \(s\equiv0\left(\text{mod}\,6\right)\).
For \(\mu=2\), \(\left(2\left(a^{2}+a\right)+2m+1-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\).
For \(\left(2\left(a^{2}+a\right)+1\right)\equiv\left\{ 1,5\right\} \left(\text{mod}\,12\right)\), \(2m\equiv\left\{ \left(0\,{or}\,8\right),\left(4\,{or}\,8\right)\right\} \left(\text{mod}\,12\right)\) respectively for \(s^{2}\equiv\left\{ \left(1\,{or}\,9\right),\left(9\,{or}\,1\right)\right\} \left(\text{mod}\,12\right)\), yielding \(m\equiv0\left(\text{mod}\,2\right)\) and \(M\equiv2\left(\text{mod}\,24\right)\). Furthermore,
if \(m\equiv0\left(\text{mod}\,6\right)\), \(a\equiv0\) or \(2\left(\text{mod}\,3\right)\) and \(s\equiv1\) or \(5\left(\text{mod}\,6\right)\);
if \(m\equiv2\left(\text{mod}\,6\right)\), \(a\equiv1\left(\text{mod}\,3\right)\) and \(s\equiv3\left(\text{mod}\,6\right)\); and
if \(m\equiv4\left(\text{mod}\,6\right)\), \(a\) can take any value and \(s\equiv1\left(\text{mod}\,2\right)\).
For \(\mu=4\), \(\left(2\left(2a^{2}+1\right)+2m-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\).
For \(\left(2\left(2a^{2}+1\right)\right)\equiv\left\{ 2,6\right\} \left(\text{mod}\,12\right)\), \(2m\equiv\left\{ \left(2\,{or}\,10\right),\left(6\,{or}\,10\right)\right\} \left(\text{mod}\,12\right)\) respectively for \(s^{2}\equiv\left\{ \left(4\,{or}\,0\right),\left(0\,{or}\,4\right)\right\} \left(\text{mod}\,12\right)\), yielding \(m\equiv1\left(\text{mod}\,2\right)\) and \(M\equiv16\left(\text{mod}\,24\right)\). Furthermore,
if \(m\equiv1\left(\text{mod}\,6\right)\), \(a\equiv0\left(\text{mod}\,3\right)\) and \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\);
if \(m\equiv3\left(\text{mod}\,6\right)\), \(a\equiv1\) or \(2\left(\text{mod}\,3\right)\) and \(s\equiv0\left(\text{mod}\,6\right)\); and
if \(m\equiv5\left(\text{mod}\,6\right)\), \(a\) can take any value and \(s\equiv0\left(\text{mod}\,2\right)\).
For \(\mu=9\), \(\left(9a^{2}+2m-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\).
For \(\left(9a^{2}\right)\equiv\left\{ 0,9\right\} \left(\text{mod}\,12\right)\), \(2m\equiv\left\{ \left(0\,{or}\,4\right),\left(0\,{or}\,4\right)\right\} \left(\text{mod}\,12\right)\) respectively for \(s^{2}\equiv\left\{ \left(0\,{or}\,4\right),\left(9\,{or}\,1\right)\right\} \left(\text{mod}\,12\right)\), yielding \(m\equiv0\) or \(2\left(\text{mod}\,6\right)\) and \(M\equiv9\) or \(33\left(\text{mod}\,72\right)\). Furthermore,
if \(m\equiv0\left(\text{mod}\,6\right)\), either \(a\equiv0\left(\text{mod}\,2\right)\) and \(s\equiv0\left(\text{mod}\,6\right)\), or \(a\equiv1\left(\text{mod}\,2\right)\) and \(s\equiv3\left(\text{mod}\,6\right)\); and
if \(m\equiv2\left(\text{mod}\,6\right)\), either \(a\equiv0\left(\text{mod}\,2\right)\) and \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\), or \(a\equiv1\left(\text{mod}\,2\right)\) and \(s\equiv1\) or \(5\left(\text{mod}\,6\right)\).
For \(\mu=11\), \(\left(11a^{2}+2a+1+2m-s^{2}\right)\equiv0\left(\text{mod}\,12\right)\).
For \(\left(11a^{2}+2a+1\right)\equiv\left\{ 1,2,5,10\right\} \left(\text{mod}\,12\right)\), \(2m\equiv\left\{ \left(0\,{or}\,8\right),\left(2\,{or}\,10\right),\left(4\,{or}\,8\right),\right.\) \(\left.\left(2\,{or}\,6\right)\right\} \left(\text{mod}\,12\right)\) respectively for \(s^{2}\equiv\left\{ \left(1\,{or}\,9\right),\left(4\,{or}\,0\right),\left(9\,{or}\,1\right),\left(0\,{or}\,4\right)\right\} \left(\text{mod}\,12\right)\) yielding
if \(m\equiv0\left(\text{mod}\,6\right)\), \(a\equiv0\) or \(2\left(\text{mod}\,6\right)\) and \(s\equiv1\) or \(5\left(\text{mod}\,6\right)\);
if \(m\equiv1\left(\text{mod}\,6\right)\), either \(a\equiv1\left(\text{mod}\,6\right)\) and \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\), or \(a\equiv3\) or \(5\left(\text{mod}\,6\right)\) and \(s\equiv0\left(\text{mod}\,6\right)\);
if \(m\equiv2\left(\text{mod}\,6\right)\), \(a\equiv4\left(\text{mod}\,6\right)\) and \(s\equiv3\left(\text{mod}\,6\right)\);
if \(m\equiv3\left(\text{mod}\,6\right)\), \(a\equiv3\) or \(5\left(\text{mod}\,6\right)\) and \(s\equiv2\) or \(4\left(\text{mod}\,6\right)\);
if \(m\equiv4\left(\text{mod}\,6\right)\), either \(a\equiv0\) or \(2\left(\text{mod}\,6\right)\) and \(s\equiv3\left(\text{mod}\,6\right)\), or \(a\equiv4\left(\text{mod}\,6\right)\) and \(s\equiv1\) or \(5\left(\text{mod}\,6\right)\); and
if \(m\equiv5\left(\text{mod}\,6\right)\), \(a\equiv1\left(\text{mod}\,6\right)\) and \(s\equiv0\left(\text{mod}\,6\right)\).
Therefore, the congruences of Table 1 hold.
◻
Further necessary conditions obtained from Beeckmans’ criteria are recorded in [17]. Within the six congruence classes covered by Theorem 3, the admissible residues modulo \(72\) reduce to \(0,1,2,9,11,16,23,24,25,26,33,35,40,47,49,50,59,64\), or \(71\left(\text{mod}\,72\right)\).
Theorem 3 should therefore be interpreted strictly as a compatibility statement: it narrows the residue classes in which a solution may occur, but it does not imply that every such class contains a solvable value of \(M\). Explicit values of \(M\) for which solutions of (3) exist are listed in [18].
A particularly interesting situation arises when \(M\) is itself a perfect square. The following theorem gives a necessary structural condition in that case.
Theorem 3. For \(M>1\in\mathbb{Z}^{+}\), if \(M\) is a square integer and there exist \(a,s\in\mathbb{Z}^{+}\) such that \(\sum\limits_{i=0}^{M-1}\left(a+i\right)^{2}=s^{2}\), then necessarily \(M\equiv1\left(\text{mod}\,24\right)\). More precisely, \(M=\left(6n-1\right)^{2}\) for some \(n\in\mathbb{Z}\), equivalently \(\left(M-1\right)/24=n\left(3n-1\right)/2\) is a generalized pentagonal number.
Proof. For \(M>1,m,m_{1},m_{2}\in\mathbb{Z}^{+}\), \(n\in\mathbb{Z}\), let \(M=m^{2}\); then \(m\neq0\left(\text{mod}\,2\right)\) and \(m\neq0\left(\text{mod}\,3\right)\) by (C1.1) and (C1.2). Therefore, \(m\equiv\pm1\left(\text{mod}\,6\right)\) \(\Rightarrow\) \(m=6m_{1}\pm1\), yielding \(M=12m_{1}\left(3m_{1}\pm1\right)+1\) or \(M\equiv1\left(\text{mod}\,12\right)\). Then, by Theorem 3, \(M\equiv1\left(\text{mod}\,24\right)\) \(\Rightarrow\) \(M=24m_{2}+1\), and \(24m_{2}+1=\left(6m_{1}\pm1\right)^{2}\), or \(m_{2}=m_{1}\left(3m_{1}\pm1\right)/2\) which is equivalent to \(n\left(3n-1\right)/2\), \(\forall n\in\mathbb{Z}\). ◻
The generalized pentagonal numbers \(n\left(3n-1\right)/2\) [19, 20] begin as \[0,1,2,5,7,12,15,22,26,35,40,51,57,\ldots,\] [21]. Consequently, \[M=1,25,49,121,169,289,361,529,625,841,961,1225,1369,\ldots.\]
The first two values must be discarded. The value \(M=1\) is excluded by the assumption \(M>1\), while for \(M=25\) the unique solution is \(a=0\) and \(s=70\), which is inadmissible because \(a\) is required to be positive. This case is, of course, equivalent to the classical solution with \(a=1\) and \(s=70\) for \(M=24\) in Lucas’ cannonball problem; see also [22].
This paper refines the congruence analysis of the Diophantine equation \[\sum\limits_{i=0}^{M-1}(a+i)^{2}=s^{2},\] by sharpening the necessary conditions on the parameter \(M\). Using Beeckmans’ criteria, we prove that no solution exists when \(M\equiv5,6,7,8\) or \(10\left(\text{mod}\,12\right)\). For the remaining congruence classes \(M\equiv0,1,2,4,9\) or \(11\left(\text{mod}\,12\right)\), we obtain stronger necessary congruence restrictions on \(M\), together with corresponding restrictions on \(a\) and \(s\). These results identify residue classes that are compatible with a solution, but they do not by themselves establish existence.
The exceptional class \(M\equiv3\left(\text{mod}\,12\right)\) was investigated by means of a recursive residue-class sieve. That analysis provides computational evidence against solvability, but a complete symbolic exclusion remains open within the scope of the present work. We also showed that, if \(M\) is itself a square and a solution exists, then necessarily \(M\equiv1\left(\text{mod}\,24\right)\) and \(\left(M-1\right)/24\) must be a generalized pentagonal number.
A general solution of the Diophantine quadratic equation (3) in the variables \(a\) and \(s\), with \(M\) treated as a parameter, is developed in the companion paper [22].
Lucas, E. (1873). Recherches Sur L’analyse Indéterminée (p. 90). Moulins.
Dickson, L. E. (2005). History of the Theory of Numbers. Vol. 1, Divisibility and primality (p. 357). Chelsea Publishing Company.
Lucas, E. (1875). Question 1180. Nouvelles Annales De Mathématiques, Série 2, 14, 336.
Moret-Blanc, M. (1876). Question 1180. Nouvelles Annales De Mathématiques, Série 2, 15, 46–48.
Lucas, É. (1877). Solution de la question 1180. Nouvelles Annales de Mathématiques, 16(2), 429-432.
Watson, G. N. (1918). The problem of the square pyramid. Messenger of Math, 48, 1-22.
Ljunggren, W. (1952). New solution of a problem proposed by E. Lucas. Norsk Mat. Tidsskr, 34, 65-72.
Ma, D. G. (1985). An elementary proof of the solutions to the Diophantine equation \(6y^2= x (x+ 1)(2x+ 1)\). Sichuan Daxue Xuebao, 4, 107-116.
Anglin, W. S. (1990). The square pyramid puzzle. The American Mathematical Monthly, 97(2), 120-124.
Alfred, B. U. (1964). Consecutive integers whose sum of squares is a perfect square. Mathematics Magazine, 37(1), 19-32.
Philipp, S. (1964). Note on consecutive integers whose sum of squares is a perfect square. Mathematics Magazine, 37(4), 218-220.
Laub, M. (1990). Squares expressible as a sum of \(n\) consecutive squares, advanced problem 6552. American Mathematical Monthly, 97, 622-625.
Beeckmans, L. (1994). Squares expressible as sum of consecutive squares. The American Mathematical Monthly, 101(5), 437-442.
Layman, J. W. (2014). Sequence A066443: Number of distinct paths of length \(2n + 1\) along edges of a unit cube between two fixed adjacent vertices. In The On-Line Encyclopedia of Integer Sequences. Retrieved March 30, 2014, from http://oeis.org/A066443
Zajos, L. (2014). Sequence A125857: Numbers whose base 9 representation is \(22222222…2.\) In The On-Line Encyclopedia of Integer Sequences. Retrieved March 30, 2014, from http://oeis.org/A125857
Sloane, N. J. A. (2014). Sequence A002452: \((9n-1)/8\). In The On-Line Encyclopedia of Integer Sequences. Retrieved March 30, 2014, from http://oeis.org/A002452
Pletser, V. (2014). Additional congruence conditions on the number of terms in sums of consecutive squared integers equal to squared integers, ArXiv. https://arxiv.org/abs/1409.6261.
Sloane, N. J. A. (2014). Numbers \(n\) such that sum of squares of \(n\) consecutive integers \(>= 1\) is a square. Sequence A001032 in The On-line Encyclopedia of Integer Sequences, published electronically at http://oeis.org, last accessed, 17 March 2026.
Euler, L. (1783). De mirabilis proprietatibus numerorum pentagonalium. Acta Academiae Scientiarum Imperialis Petropolitanae, 56-75.
Weisstein, E. W. (2014). Pentagonal number. In MathWorld—A Wolfram Web Resource. Retrieved August 10, 2014, from http://mathworld.wolfram.com/PentagonalNumber.html.
Sloane, N. J. A. (2014). Generalized pentagonal numbers: \(n*(3* n-1)/2, n= 0,+-1,+-2,+-3.\) Sequence A001318 in The On-line Encyclopedia of Integer Sequences, published electronically at http://oeis.org, last accessed, 10 March 2026.
Pletser, V. (2014). Finding all squared integers expressible as the sum of consecutive squared integers using generalized Pell equation solutions with Chebyshev polynomials. https://arxiv.org/abs/1409.7972.