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