Skip to content

Commit c791962

Browse files
authored
Add function to calculate pyramid height
1 parent 2cf151b commit c791962

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import math
2+
def calculate_pyramid_height(number_of_blocks):
3+
if number_of_blocks <= 0:
4+
return 0
5+
height = (-1 + math.sqrt(1 + 8 * number_of_blocks)) / 2
6+
return math.ceil(height)
7+
print(calculate_pyramid_height(11))

0 commit comments

Comments
 (0)