Given that the sum of the squares of the first $n$ integers is $\frac{n(n+1)(2 n+1)}{6}$, determine the necessary and sufficient condition for the sum of the squares of $p$ consecutive integers

$$
(a+1)^{2}+(a+2)^{2}+\ldots+(a+p)^{2}
$$

to be divisible by $p$.
The sum of the squares of $p$ consecutive integers:

$$
\begin{gathered}
S=(a+1)^{2}+(a+2)^{2}+\cdots+(a+p)^{2}= \\
=p a^{2}+2 a(1+2+\cdots+p)+1^{2}+2^{2}+\cdots+p^{2}= \\
=p a^{2}+a p(1+p)+\frac{p(p+1)(2 p+1)}{6} .
\end{gathered}
$$

Since each term in this expression is divisible by $p$, the necessary and sufficient condition for $\frac{S}{p}$ to be an integer is that $\frac{(p+1)(2 p+1)}{6}$ is an integer. Let's find the form of $p$ for which $(p+1)(2 p+1)$ is divisible by 6, i.e., by 2 and 3.

There are two possible cases. Since $2 p+1$ is not divisible by 2, the product $(p+1)(2 p+1)$ is divisible by 6 if

$1^{\circ} . \quad p+1=2 m$ and $(2 p+1)=3 l$.

If we subtract three times the first equation from twice the second equation, we get

$$
p=6(l-m)+1=6 u+1
$$

$2^{\circ}$. The product $(p+1)(2 p+1)$ is also divisible by 6 if $(p+1)$ is divisible by 6, i.e., if

$$
\frac{p+1}{6}=u, \text { or } p=6 u-1 \text { form. }
$$

Thus, it is divisible by 6 if $p=6 u \pm 1$.

(Imre Csada, Pápa.)

The problem was also solved by: Bánó L., Dömény I., Erdős V., Fekete M., Fodor H., Földes R., Fuchs I., Haar A., Heimlich P., Jánosy Gy., Kiss J., Krampera Gy., Messer P., Pám M., Paunz A., Rosenberg J., Ruvald S., Sárközy P., Schuster Gy., Schwarz Gy., Mathematical Circle, Budapest, V. district gymnasium.