Skip to content

Instantly share code, notes, and snippets.

@aashish-chaubey
Created August 6, 2022 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aashish-chaubey/802464cdebffffb40aa56d53b9077d97 to your computer and use it in GitHub Desktop.
Save aashish-chaubey/802464cdebffffb40aa56d53b9077d97 to your computer and use it in GitHub Desktop.
Find all the numbers between 1-50 and print them in a list
import math
l = 50
def is_prime(num: int) -> bool:
lim = math.floor(math.sqrt(num))
for i in range(2, lim+1):
if num % i == 0:
return False
return True
prime_numbers = filter(is_prime, list(range(2, l+1)))
print(list(prime_numbers))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment