Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / How many blocks in a pyramid?

Author
Message
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Aug 2010 19:11
This seems like a pretty simple maths problem but I can't find an answer!
I want a formula that will return the number of blocks in a pyramid given the number in the base.

I only want this for a 2D pyramid where n is the height of the pyramid and also the number of blocks in the base.

I know you can say

but there must be a proper formula for working this out.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Aug 2010 21:51
It's fairly easy:

Row 1: 1 block
Row 2: 2 blocks
Row 3: 3 blocks
Row 4: 4 blocks
Row 5: 5 blocks

It's easy to see the progression from that. If you draw it out in a certain way, then you can work out the formula fairly easily:

#xxxxx
##xxxx
###xxx
####xx
#####x

=> (5 * (5 + 1)) / 2
=> (5 * 6) / 2
=> 30 / 2
=> 15 ... which happens to be the right answer.

In general, the formula would by (n * (n + 1)) / 2 which works for any number of rows.

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Aug 2010 06:58 Edited at: 22nd Aug 2010 07:08
Ah, thanks Ian.

so a 3D one would be

x = blocks
1 = 1
2 = 5 = 4+1
3 = 14 = 9+5
4 = 30 = 16+14
n = ? = n^2+?

blocks = n^2*(n+1)/2 ?

no i need to think about this

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Aug 2010 12:33
Quote: "no i need to think about this"


Just do what Ian did for 2D:
1
4
9
16
.
.
.
n^2

so you want the sum of the first n squares. It's a standard result from school maths:

(n * (n + 1) * (2n + 1)) / 6

Use Google.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Aug 2010 05:38
Thanks, my maths sucks.
I did use google it had nothing useful.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Aug 2010 21:13
Quote: "I did use google it had nothing useful."


I guess you asked the wrong question. Through sheer laziness I got the answer from Google immediately. I searched for formula for the sum of squares and one result even gave the formula in the Google summary.

Login to post a reply

Server time is: 2025-05-21 04:44:11
Your offset time is: 2025-05-21 04:44:11