[−][src]Function primecount::nth_prime
pub fn nth_prime(n: i64) -> i64
Find the n
th prime using a combination of the prime counting
function and the sieve of Eratosthenes.
@pre n <= 216289611853439384
Returns -1 if an error occurs.
Examples
assert_eq!(primecount::nth_prime(1), 2); assert_eq!(primecount::nth_prime(5), 11); assert_eq!(primecount::nth_prime(455052511), 9999999967);
- Run time: O(x^(2/3) / (log x)^2)
- Memory usage: O(x^(1/2))