Skip to content

Commit 61ff6af

Browse files
fix: memperbaiki algoritma
1 parent e2c7d6f commit 61ff6af

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

other/lucky_number.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def is_lucky_number(number):
99
'Angka Lucky'
1010
>>> is_lucky_number(21)
1111
'Angka Lucky'
12+
>>> is_lucky_number(9)
13+
'Angka Lucky'
14+
>>> is_lucky_number(10)
15+
'Bukan Angka Lucky'
1216
>>> is_lucky_number(1232)
1317
'Bukan Angka Lucky'
1418
>>> is_lucky_number(700)
@@ -21,7 +25,8 @@ def is_lucky_number(number):
2125
idx = 1
2226
nbr = []
2327
for i in range(1 , MAX_NUMBER):
24-
nbr.append(i)
28+
if i % 2 != 0:
29+
nbr.append(i)
2530

2631
while idx < len(nbr):
2732
step = nbr[idx]
@@ -50,6 +55,8 @@ def main(args=None):
5055

5156
print(is_lucky_number(1)) # Angka Lucky
5257
print(is_lucky_number(21)) # Angka Lucky
58+
print(is_lucky_number(9)) # Angka Lucky
59+
print(is_lucky_number(10)) # Bukan Angka Lucky
5360
print(is_lucky_number(80)) # Bukan Angka Lucky
5461
print(is_lucky_number(897)) # Bukan Angka Lucky
5562

0 commit comments

Comments
 (0)