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.

  • $\begingroup$ Don't you mean m x m squares? $\endgroup$
    – CodeNewbie
    Commented Jun 17, 2016 at 5:40
  • $\begingroup$ No, I mean $n \times n$ squares. $\endgroup$ Commented Jun 17, 2016 at 5:42
  • $\begingroup$ you could have said n>3 it make no difference $\endgroup$
    – Jasen
    Commented Jun 17, 2016 at 6:23
  • $\begingroup$ 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". $\endgroup$
    – dpwilson
    Commented Jun 17, 2016 at 15:06

3 Answers 3


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

but I wrote software to find that



while true
 (( 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 ) ))


[edit] 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.

  • $\begingroup$ not particularly well written even. $\endgroup$
    – Jasen
    Commented Jun 17, 2016 at 6:25
  • 1
    $\begingroup$ This can be even solved without programming. $\endgroup$ Commented Jun 17, 2016 at 8:01
  • 4
    $\begingroup$ @ M Oehm: I have no problem with this solution. I just said that so that others can try manually. $\endgroup$ Commented Jun 17, 2016 at 8:22
  • 4
    $\begingroup$ @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. $\endgroup$
    – CodeNewbie
    Commented Jun 17, 2016 at 8:44
  • 1
    $\begingroup$ I would also like to see how to solve this manually $\endgroup$
    – Jasen
    Commented Jun 17, 2016 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:


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


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


Rearranging to find $n$ yields:


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$.

  • $\begingroup$ 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$. $\endgroup$ Commented Jun 21, 2016 at 14:38
  • $\begingroup$ @JaapScherphuis: Good catch; that would make it a bit faster. $\endgroup$
    – dpwilson
    Commented Jun 21, 2016 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


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.)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.