Untitled
unknown
plain_text
10 months ago
411 B
4
Indexable
def is_prime(num):
if num < 2:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def nth_prime(n):
count = 0
num = 1
while count < n:
num += 1
if is_prime(num):
count += 1
return num
# Input
n = int(input("Enter the value of n: "))
print(f"The {n}th prime number is {nth_prime(n)}")Editor is loading...
Leave a Comment