# Egyptian square pyramid

If you have $140$ stone blocks, you can build an Egyptian square pyramid whose base has $7$ blocks on each side. At the same time, you can arrange those blocks into $35$ perfect 2 × 2 squares. Find a positive integer value of $n \gt 1000$ for which $35$ perfect $n \times n$ squares can also be arranged into an Egyptian square pyramid.

• Don't you mean m x m squares? – CodeNewbie Jun 17 '16 at 5:40
• No, I mean $n \times n$ squares. – Anurag Jain Jun 17 '16 at 5:42
• you could have said n>3 it make no difference – Jasen Jun 17 '16 at 6:23
• Sooooooo this is the Square Pyramid Puzzle with an extra factor of $35$ in front? If so, the proof is not simple, although it is technically "elementary". – dpwilson Jun 17 '16 at 15:06

n=2378, the pyramid's base is 840 square

but I wrote software to find that

#!/bin/bash

p=1
n=999

while true
do
(( pp= p*(p+1)*(p*2+1) / 6 )) # formula for square pyrimadal numbers
(( nn=35 * n * n ))           # 35 squares

echo "p=$p n=$n pp=$pp nn=$nn" # show progress
(( pp == nn )) && break        # stop when a solution is found
(( n+= ( pp > nn ) ))
(( p+= ( nn > pp ) ))

done


 We are now told that this solution can be found by manual means the next solution if there is any is up past one million, so it's likely that this one is findable.

It seems we have a diophantine equation

$210n^2 = p*(p+1)*(2p+1)$

but I can't see how to proceed.

• not particularly well written even. – Jasen Jun 17 '16 at 6:25
• This can be even solved without programming. – Anurag Jain Jun 17 '16 at 8:01
• @ M Oehm: I have no problem with this solution. I just said that so that others can try manually. – Anurag Jain Jun 17 '16 at 8:22
• @Human: If you would rather prefer a manual solution (as would I), I suggest you leave the question without an accepted answer. An question with an accepted answer will draw lesser views, and reduce the chances of seeing that elegant solution. – CodeNewbie Jun 17 '16 at 8:44
• I would also like to see how to solve this manually – Jasen Jun 17 '16 at 22:55

Here's a solution by hand. It's still a little brute-forcey but certainly plausible (if a tad tedious) to do without a computer. (I can confirm, as I did the whole thing on paper.) The result confirms Jasen's answer of

$n=2378$; pyramid base size of $840$; $1187525640$ total blocks

We're searching for a number $n > 1000$ for which $35$ $n\times{}n$ squares can be arranged into an Egyptian square pyramid. Calling the total number of blocks $P$, this can be expressed as the following equation:

$P=35n^2$.

with the stipulation that $P$ is a square pyramidal number. These numbers are well known, and there is a handy formula for computing them. For any positive integer $m$, the $m$th square pyramidal number can be found using

$\frac{m(m+1)(2m+1)}{6}$.

Therefore, we're hunting for integers $n>1000$ and $m>0$ that satisfy the equation

$\frac{m(m+1)(2m+1)}{6}=35n^2$.

Rearranging to find $n$ yields:

$n=\sqrt{\frac{m(m+1)(2m+1)}{210}}$.

This tells us that the numerator is divisible by $210$, and the whole expression under the radical must be a perfect square. Since $m$ is an integer, so must the other terms in the numerator be. The simplest way to ensure the numerator is divisible by $210$ is to assume $210\vert m$. Then it's a matter of doing some fairly simple hand calculations over $m=210, 420, 630, 840$, etc., using some simple tricks to check if the result is a perfect square.

• $m=210\rightarrow 1*211*421$. The last digit is $1$, so this could be a perfect square. However, the 10s digit is a $3$, so this cannot be a PS.
• $m=420\rightarrow 2*421*841$. The last digit is $2$, so this is not a PS.
• $m=630\rightarrow 3*631*1261$. The last digit is $3$, so this is not a PS.
• $m=840\rightarrow 4*841*1681$. The last digit is $4$, so that doesn't rule this out yet. Last two digits are $84$, so this could still potentially be a PS. Alright, fine, multiplying it out yields $5654884$. If you're like me, you probably don't have all the squares up through four digits memorized. However, I do know all the ones up to $30$. Noting that $23^2=529$ and $24^2=576$, the number is between $2300$ and $2400$. Maybe someone out there knows a more efficient way to find the square root of a (fairly) large number, but for me it involves a lot of oscillating until I stumble upon it. Spoiler alert: It's $2378$. Thankfully all that work didn't go to waste, since I had no real assurance that that number was, in fact, a perfect square.

Therefore we have found $n=2378$ and $m=840$.

• You could have noticed that $4$ and $841$ are both squares, so you then only need to check that $1681$ is also square. It is fairly obviously a bit more than $40^2=1600$. In fact, it is $40^2+2*40+1$ $=$ $(40+1)^2$ $=$ $41^2$, so you get $n=2*29*41$. – Jaap Scherphuis Jun 21 '16 at 14:38
• @JaapScherphuis: Good catch; that would make it a bit faster. – dpwilson Jun 21 '16 at 19:34

So far, the nearest thing I have found to a way of solving it by hand is the following: if you happen to remember that 841 and 1681 are both squares (which you very well might, especially if for any reason you've been looking at rational approximations to $\sqrt{2} lately) then on seeing$210n^2=p(p+1)(2p+1)$you might say: Hmm, perhaps we can make two of those factors on the RHS be squares and the other one deal with the 210;$p=210$doesn't work, but aha!,$4\times210=840$and if we take that as$p$then both$p+1$and$2p+1\$ are squares, and we're done.

But this is entirely dependent on spotting something distinctly non-obvious; it doesn't offer an actual method that leads to the answer.

(In general, this kind of problem -- a cubic polynomial in one variable equals a quadratic in another -- is a matter of finding integer points on elliptic curves, and the usual method for this is "run SAGE or Magma on your computer and get it to solve the problem", which it will do by means of advanced mathematics and a lot of calculation. So if there's a method that solves this problem by hand without the sort of flash of insight described above, it will need to be one quite specific to the particular problem.)

• Yeaahh, I kept hitting the wall of finding points on an ellipse, which seems far too complicated for a puzzler to do "by hand". – dpwilson Jun 20 '16 at 11:26