Skip to content

Instantly share code, notes, and snippets.

@KAnanev
Created December 5, 2023 08:27
Show Gist options
  • Save KAnanev/57d8ba62c93e954f7e8204da45122663 to your computer and use it in GitHub Desktop.
Save KAnanev/57d8ba62c93e954f7e8204da45122663 to your computer and use it in GitHub Desktop.
prime in python
def eratoshenes_effective(num):
numbers = list(range(num + 1))
numbers[0] = numbers[1] = False
for i in range(2, num):
if numbers[i]:
for j in range(i * i, num + 1, i):
numbers[j] = False
return numbers
def is_prime(num: int):
if num == 1:
return False
count = 2
while count < num:
if num % count == 0:
return False
count += 1
return True
def is_prime(num):
if num == 1:
return False
count = 2
while count * count <= num:
if num % count == 0:
return False
count += 1
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment