19 lines
358 B
Python
Executable File
19 lines
358 B
Python
Executable File
def nth_prime_number(n):
|
|
if n==1:
|
|
return 2
|
|
count = 1
|
|
num = 1
|
|
while(count < n):
|
|
num +=2 #optimization
|
|
if is_prime(num):
|
|
count +=1
|
|
return num
|
|
|
|
def is_prime(num):
|
|
factor = 2
|
|
while (factor * factor <= num):
|
|
if num % factor == 0:
|
|
return False
|
|
factor +=1
|
|
return True
|