Skip to content

Commit ec6f664

Browse files
authored
Update pyramid_esra_kaya.py
1 parent 887e974 commit ec6f664

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

Week03/pyramid_esra_kaya.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
def calculate_pyramid_height(kup_sayisi):
2-
if kup_sayisi <= 0:
3-
return "Küp sayısı sıfırdan büyük olmalıdır."
1+
def calculate_pyramid_height(cube_number):
2+
total_cube = 0
3+
height = 0
44

5-
toplam_kup = 0
6-
yukseklik = 0
7-
8-
while toplam_kup < kup_sayisi:
9-
yukseklik += 1
10-
toplam_kup += yukseklik
11-
12-
if toplam_kup == kup_sayisi:
13-
return yukseklik
14-
15-
# Eğer toplam_kup, kup_sayisi'ni aşarsa bu piramit oluşturulamaz.
16-
return "Bu küp sayısıyla bir piramit oluşturulamaz."
5+
while total_cube < cube_number:
6+
height += 1
7+
total_cube += height
8+
if total_cube == cube_number:
9+
return height

0 commit comments

Comments
 (0)