Skip to content

Instantly share code, notes, and snippets.

@SanjarbekSaminjonov
Last active October 2, 2022 11:55
Show Gist options
  • Save SanjarbekSaminjonov/a344d88a7ada86919c15d3ddebfcf3de to your computer and use it in GitHub Desktop.
Save SanjarbekSaminjonov/a344d88a7ada86919c15d3ddebfcf3de to your computer and use it in GitHub Desktop.
import math
import time
def is_prime(number: int, prime_numbers: list) -> bool:
if number < 2:
return False
root_of_number = int(math.sqrt(number))
for devider in prime_numbers:
if devider > root_of_number:
return True
if number % devider == 0:
return False
return True
def get_prime_numbers(to: int) -> list:
prime_numbers = list()
for number in range(1, to + 1):
if is_prime(number, prime_numbers):
prime_numbers.append(number)
return prime_numbers
if __name__ == '__main__':
start_time = time.time()
print(get_prime_numbers(100000))
end_time = time.time()
print(f'--- {end_time - start_time} seconds ---')
# by Sanjarbek Saminjonov
@SanjarbekSaminjonov
Copy link
Author

Bu yer comment uchun 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment