forked from fenyx-it-academy/Class4-PythonModule-Week2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlucky numbers
More file actions
25 lines (21 loc) · 845 Bytes
/
lucky numbers
File metadata and controls
25 lines (21 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Original sequence: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
# Remove 2nd elements: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
# Remove 3rd elements: [1, 3, 7, 9, 13, 15, 19, 21]
# Remove 4th elements: [1, 3, 7, 13, 15, 19]
# Remove 5th elements: [1, 3, 7, 13, 19]
# We cannot remove every other 6th element as there is no 6th element.
# Input>>> 22
# Output>>> Lucky numbers are [1, 3, 7, 13, 19]
sayi=int(input("lutfen bir sayi giriniz: "))
liste=[]
#bu for loopuyla kullanicinin girdigi sayi kadar bir liste olusturulmaktadir.
for i in range(1,sayi+1):
liste.append(i)
a=2
#bu for loopu ile 2`den baslayarak birer artarak listeden elemanlar siliniyor ve son olarak lucky numbers kaliyor
for i in range(1,len(liste)):
del liste[a-1::a]
a+=1
if len(liste)==a:
break
print(liste)