Created
September 19, 2022 16:39
-
-
Save hsfzxjy/ba8ebbfca8ebaae2be9c89b5daa47ff2 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
from math import ceil, sqrt | |
def isprime(n): | |
for x in range(2, ceil(sqrt(n + 1))): | |
if n % x == 0: | |
return False | |
return True | |
def prime(n): | |
if n == 0: | |
return | |
print("2 ", end=" ") | |
counter = 1 | |
x = 3 | |
while counter < n: | |
if isprime(x): | |
print(x, "", end=" ") | |
counter += 1 | |
x += 2 | |
if counter % 10 == 0: | |
print() | |
n = int(input()) | |
prime(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment