Proving the Sum of Squares in Minecraft
Imagine starting out with a cube of length 1.
Stack this one cube upon a base of 4 cubes, in the corner.
We can see that this makes 4 + 1 = 5 cubes:
Take this 5-cube structure and stack this on a base of nine cubes. Continue indefinitely, like so:
The number of blocks needed to build one of these is:
1² + 2² + 3² + 4² + . . . n².
(For example, for a structure with a bottom layer of 3x3, the number of blocks needed would be 3² for the bottom layer, plus 2² for the middle layer, and 1² for the top block.)
We can stack two of them together like this:
Now that we have two of these together, one at an angle, we need to double the formula.
Total blocks: 2*(1² + 2² + 3² + 4² + . . . n²).
Okay, let’s add one more of these staircase shapes. Note that I’m adding the exact same shape each time, just in a different orientation.
The total number of blocks used is now 3*(1² + 2² + 3² + 4² + . . . n²).
We can see that after 3 of these staircase shapes, the big cuboid is missing exactly half of its side. That is, it has the area of ½ of an n+1 by n+1 cube.
Let’s pretend the “half square” bit isn’t there, and consider the dimensions of the complete cuboid. I’ve replaced the half-square with glass for clarity.
This side is n+1 blocks, or 5 blocks long:
This side is n blocks, or 4 blocks wide (remembering to ignore the glass half-side):
The whole thing is n blocks, or 4 blocks tall.
The total area without the half-square side is 4*4*5 or n*n*(n+1).
We can add in the half-square side, which is simply half of an n by n+1 square, to get the total area, which is 4*4*5 + (4*5)/2 or n*n*(n+1) + (n*(n+1))/2. However, this is three sums of squares, not one.
We can say that 3*(1² + 2² + 3² + 4² + . . . n²) = n*n*(n+1) + (n*(n+1))/2
Divide both sides by three to get:
1² + 2² + 3² + 4² + . . . n² = (n*n*(n+1) + (n*(n+1))/2)/3, which is the same as:
(n*(1 + n)*(1 + 2n))/6
Another way of seeing it is if we had two of these big cuboids (six staircases total), we’d have two of these half-sides, which would make a full side, that is, an n by n+1 square.
The number of blocks used would be 6*(1² + 2² + 3² + 4² + . . . n²).
The total area would be two n by n by n+1 cubes, with a single additional n by n+1 square face.
This is 2*(n*n*(n+1)) + n*(n+1).
So, we can write: 6*(1² + 2² + 3² + 4² + . . . n²) = 2*(n*n*(n+1)) + n*(n+1)
Then divide by six, because we used six sums (the “staircases” from 1² to n²).
This yields (2*(n*n*(n+1)) + n*(n+1))/6, which is the same as:
(n*(1 + n)*(1 + 2n))/6
We can see this will hold for any n.