Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python nth prime function

def is_prime(n): 
	if n>1: 
		divs=[k for k in range(2,n) if n%k==0] 
		return len(divs)==0 
	else: 
		return False 
		 
def nth_prime(n): 
	primes=[p for p in range(n*n+2) if is_prime(p)] 
	return primes[n-1]
Source by www.quora.com #
 
PREVIOUS NEXT
Tagged: #python #nth #prime #function
ADD COMMENT
Topic
Name
5+6 =