Math of Human Pyramids I was writing a blog post today, and I ended up asking the question of how many layers tall a human pyramid would be if it contained all of the people who use Facebook, approximately 750 million.
First I had to define how the pyramid would work. Basically, I ended up with $n$ being the number of layers from the top, and $n^2$ being the number of people in that layer. 
So the top layer would be $n=1$ and would contain $n^2=1$ people. Next layer would be $n=2$ and would contain $n^2=4$ people.
I ended up writing a simple python script to answer the question, but now I'm wondering about a more generalized answer. 
Given $x$ people, how tall would the pyramid be?
There's quite possibly a very simple answer to this, but I don't know what it would be.
 A: As yunone has pointed out, there is a formula for the sum of squares, namely
$$\sum_{k=1}^n k^2 = \frac{n(n + 1)(2n + 1)}{6} .$$
So if the sum is about $x$ then $n$ is slightly less than $\sqrt[3]{3x}$, and for large $x$, $\sqrt[3]{3x}-\tfrac{1}{2}$ is a good estimate.  With $x=750,000,000$, this suggests something about $1309.87$.  Indeed the the sum of the first $1310$ squares is $750,221,935$.
You will also need to multiply by the average height of each layer (remembering that most human pyramids stand on shoulders rather than heads).
A: The sum of the squares of the first $n$ natural numbers is given by:
$$x = \frac{n(n+1)(2n+1)}{6}$$
Hence, you need to find $n$ in terms of $x$ using the following equation:
$$ n(n+1)(2n+1) - 6x = 0$$
Hence you need to find the real root of the cubic function
$$2n^3 + 2n^2 + n^2 + n - 6x$$
given by $n = $

Thus, for $x = 750,000,000$, we get $n = \lfloor 1309.9 \rfloor $ or $1309$ levels. 
Using the average height of a male in the US (1.776m), that's a 2324.8m high pyramid made of $748,505,835$ people!
Here's the closed-form solution in pseudocode:
n = 1/(12*((3*x)/2 + ((9*x^2)/4 - 1/1728)^(1/2))^(1/3)) + ((3*x)/2 + ((9*x^2)/4 - 1/1728)^(1/2))^(1/3) - 1/2

