Suppose you have a square pyramid made out of rigid balls and all these balls are equal. Suppose now that you want to fill a square with the same number of balls that the pyramid is made. If $x$ denotes the size of the square and $y$ denotes the size of the base square of the pyramid, then the problem is equivalent to find the integer solution of the following equation:
$$|\{\text{balls in the square}\}|=x^2=\sum_{i=1}^yi^2=\frac{y(y+1)(2y+1)}{6}=|\{\text{balls in the pyramid}\}|$$
In other words, we want to find the pairs $$(\text{size of square},\text{size of base square of pyramid})=(\Box,\triangle)\in\mathbb{Z}^2$$ for which the following polynomial vanishes:
$$\mathbb{Z}[x,y]\ni6x^2-2y^3-3y^2-y$$
Well, if $(\Box,\triangle)$ is a solution, then $(-\Box,\triangle)$ is also a solution. One can easily check that there aren't solution with $\triangle<0$ and with $\triangle<0$ and $\Box<0$, so we can fix our attention at $\Box\geq 0$ and $\triangle\geq 0$ (and these solutions makes sense in view that we cannot construct the square nor the pyramid with these numbers being negative). The trivial ones are $(0,0)$ and $(1,1)$. I heard that the only other solution is $(70,24)$, but it is not trivial to prove it.
I also heard that there's an article that solves this, but I couldn't find it. If a demonstration of this is too long for an answer, you could give me references on where to find a demonstration. Thanks in advance!
This goes by the name of cannon ball problem. A quick google search gives you all the relevant information including the articles which have proofs.