Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4bef8cb

Browse filesBrowse files
committed
Added the lucky numbers algorithm
1 parent 681901d commit 4bef8cb
Copy full SHA for 4bef8cb

File tree

1 file changed

+15
-0
lines changed
Filter options

1 file changed

+15
-0
lines changed

‎math/lucky_numbers.py

Copy file name to clipboard
+15Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.