Skip to content

Instantly share code, notes, and snippets.

@SSARCandy
Last active April 9, 2023 03:18
Show Gist options
  • Save SSARCandy/14f339cf0d5b5b4a2069b0a51fbbc2b1 to your computer and use it in GitHub Desktop.
Save SSARCandy/14f339cf0d5b5b4a2069b0a51fbbc2b1 to your computer and use it in GitHub Desktop.
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