Created
August 6, 2022 07:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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