# Cannonballs packing

A pile of cannonballs stacked like a pyramid has a rectangular base. Each layer has a length and a width in terms of cannonballs that are each one less than those of the layer that is directly below. The highest layer has a width of 1 and a length that is qual to the width of the first layer. For example, if the bottom layer has a width of 2 and a length of 3, this pile meets the criteria. What are all the piles that have a number of cannonballs that is a square number?

• Is this a puzzle, or just another mathematical query? – Daniel Mathias Jun 14 at 2:27
• Sorry, you seem to have left out the "e" in "equal". – Scratch---Cat Jun 14 at 4:14
• They are all points on an elliptic curve. – Carl Löndahl Jun 14 at 12:36

Well, I find that the number of balls in a stack of height $$n$$ is

$${n(n+1)(5n-2)}\over{6}$$

Using this formula and testing for squares, I found three before 64 bit integers overflowed.

$$\begin{array} {|c|c|c|} \hline \text{Height} & \text{Cannonballs} & \text{Square Size} \\\hline 1 & 1 & 1 \\\hline 6 & 196 & 14 \\\hline 49 & 99225 & 315 \\\hline \end{array}$$

The first two are fairly easy. The third is conceivable. There might be more, but they would by millions of layers thick, and would crush the cannonballs.

Edit: I rewrote in python and found no other viable piles up to a height of one billion.

Edit: combining several comments from justhalf, we get that $$n$$ must be of the form $$a^2$$, $$2{a^2}$$, $$3{a^2}$$, or $$6{a^2}$$ for integer $$a$$. This allows the search space to be greatly reduced. I have thus now tested all $$n$$ up to nine hundred trillion ($$9*{10}^{14}$$) without finding more squares. If these cannonballs are one millimeter in diameter (which qualifies them as shotgun pellets), the base of the stack would be 6 AU by 12 AU, enough to partly cover the orbit of Jupiter.

Edit: I've now passed 10 quadrillion ($${10}^{16}$$) without another square. 66.8AU by 133.7 AU, larger than the orbit of Neptune, and covering a lot of Pluto. I don't expect to find another square.

• $n$ and $n+1$ are relatively prime, $n+1$ and $5n-2$ have only 7 as possible common denominator, and $n$ and $5n-2$ have only 2 as possible common denominator. You can start from there I guess, to prove or disprove existence of other $n$s. – justhalf Jun 14 at 3:41
• @justhalf Will that help prove or disprove entries of the form $a^2, 2{b}^2, 3{c}^2$ like the height 49 entry? Actually, we can discount the common denominator of 2: There must be an odd number of factors of 2, so we can eliminate the odd multiple and leave the even as part of the square part of the other term. – David G. Jun 14 at 11:57
• Not sure, since I haven't done the proof. But seems plausible to appear as one of the cases. For example, we know that $n$, $n+1$, and $5n-2$ should be in the form of $c_0s_0^2$, $c_1s_1^2$, and $c_2s_2^2$ with $\prod c_i = 6c^2$ for some $c$. Combine this with the possible common denominator restriction. – justhalf Jun 14 at 12:13
• I’ve noticed that this question is related to another one called the Cannonball Problem. – Display maths Jun 14 at 20:18
• As @CarlLöndahl noted in his comment, this is an elliptic curve ($y^2=cubic$). You could derive infinitely many rational points from the solutions you already have (e.g. $(\frac{64}{125},\frac{168}{625})$ ) but there can be only finitely many integer ones. It seems likely to me that the three you found are all of them, but that is probably quite hard to prove. – Jaap Scherphuis Jun 15 at 8:47

This kind of questions are quite frequently asked on the math sites.

Please refer to the book of Silverman (Arithmetic of Elliptic Curves) for the general theory.

There are computer algebra systems that can find the integral points of (many) elliptic curves over number fields.

For this example:

We write down the equation $$6m^2 = n(n + 1)(5n - 2).$$ A change of variable $$y = 180 m$$, $$x = 30n$$ gives $$y^2 = x(x + 30)(x - 12) = x^3 + 18 x^2 - 360 x.$$ This is a Weierstrass model for the curve.

Now paste the following

E = EllipticCurve([0, 18, 0, -360, 0])
for P in E.integral_points():
if P % 30 == 0:
print((P / 30, P / 180))


(-1, 0)

which gives us all the integral solutions $$(m, n)$$ to our original equation.