Sambo and Edison found some small paper cups that I purchased a while ago and have been busily making towers and pyramids. This morning Edison pulled out the cups again and started making 2- and 3-dimensional pyramids. I started asking him questions and eventually he posed the question: "I wonder if there is an equation to explain this?"
I thought of the 3-dimensional equation as 1^2 + 2^2 + 3^2 + 4^2 + 5^2 + ...x^2.
Edison whipped out the following for 3-dimensional pyramids:
var number = 0;
var stack = 5;
for(var i = 0; i <= stack; i++){
number += pow(i, 2);
}
fill(255, 0, 0);
text(number, 100, 100);
And for 2-dimensional pyramids:
var number = 0;
var stack = 5;
for(var i = 0; i <= stack; i++){
number += i;
}
fill(255, 0, 0);
text(number, 100, 100);
If you enter the above into Khan Academy, changing the "var stack" number to whatever you want the length of one of the sides of the base of the pyramid to be, the answer of "how many cups will you need?" will appear in the box to the right. Go and try it!