We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 887e974 commit ec6f664Copy full SHA for ec6f664
Week03/pyramid_esra_kaya.py
@@ -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."
+def calculate_pyramid_height(cube_number):
+ total_cube = 0
+ height = 0
4
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."
+ while total_cube < cube_number:
+ height += 1
+ total_cube += height
+ if total_cube == cube_number:
+ return height
0 commit comments