Skip to content

Commit 6d2ad66

Browse files
authored
Added the lucky numbers algorithm (#53)
Added the lucky numbers algorithm
2 parents 4652400 + 4bef8cb commit 6d2ad66

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

math/lucky_numbers.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def generate_lucky_number_sequence(end):
2+
3+
#create a list of all odd numbers up to the final number
4+
sequence = [*range(1, end+1, 2)]
5+
6+
#remove every xth number from the list where x = the nth element of the sequence
7+
n = 1
8+
while len(sequence) > sequence[n]:
9+
number_to_delete = sequence[n]
10+
del sequence[number_to_delete-1::number_to_delete]
11+
n = n + 1
12+
13+
return sequence
14+
15+
print(generate_lucky_number_sequence(int(input("Please enter the upper bound of the lucky number sequence: "))))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy