diff --git a/Week03/pyramid_aysegul_yildiz.py b/Week03/pyramid_aysegul_yildiz.py new file mode 100644 index 00000000..0564077c --- /dev/null +++ b/Week03/pyramid_aysegul_yildiz.py @@ -0,0 +1,11 @@ +import math + +def calculate_pyramid_height(n: int) -> int: + if n <= 0: + return 0 + + # h(h+1)/2 <= n → h ≤ (sqrt(1 + 8*n) - 1) / 2 + + h = (math.isqrt(1 + 8*n) - 1) // 2 + return int(h) +