Skip to content

Instantly share code, notes, and snippets.

@SSARCandy
Last active April 9, 2023 03:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
N = 5_000_000
x = 0
for number in range(1, N + 1):
if is_prime(number):
x += 1
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment