def prime(nth):
 n = as_int(nth)
 if (n < 1):
  raise ValueError('nth must be a positive integer; prime(1) == 2')
 if (n <= len(sieve._list)):
  return sieve[n]
 from sympy.functions.special.error_functions import li
 from sympy.functions.elementary.exponential import log
 a = 2
 b = int((n * (log(n) + log(log(n)))))
 while (a < b):
  mid = ((a + b) >> 1)
  if (li(mid) > n):
   b = mid
  else:
   a = (mid + 1)
 n_primes = primepi((a - 1))
 while (n_primes < n):
  if isprime(a):
   n_primes += 1
  a += 1
 return (a - 1)

def prime ( nth ) : n = as_int ( nth ) if ( n < 1 ) : raise ValueError ( 'nth must be a positive integer; prime(1) == 2' ) if ( n <= len ( sieve . _list ) ) : return sieve [ n ] from sympy . functions . special . error_functions import li from sympy . functions . elementary . exponential import log a = 2 b = int ( ( n * ( log ( n ) + log ( log ( n ) ) ) ) ) while ( a < b ) : mid = ( ( a + b ) >> 1 ) if ( li ( mid ) > n ) : b = mid else : a = ( mid + 1 ) n_primes = primepi ( ( a - 1 ) ) while ( n_primes < n ) : if isprime ( a ) : n_primes += 1 a += 1 return ( a - 1 )
return the nth prime .