Skip to content

Commit 1f99e42

Browse files
authored
Add function to calculate pyramid height
1 parent 8415c79 commit 1f99e42

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def calculate_pyramid_height(n):
2+
height = 0
3+
blocks = 0
4+
5+
while blocks + height + 1 <= n:
6+
height += 1
7+
blocks += height * height
8+
9+
return height

0 commit comments

Comments
 (0)