primecountpy.primecount

Interface to the primecount C++ library

primecountpy.primecount.nth_prime(n)

Return the n-th prime integer.

EXAMPLES:

>>> from primecountpy.primecount import nth_prime

>>> nth_prime(168) == 997
True
primecountpy.primecount.phi(x, a)

Return the number of integers smaller or equal than x by any of the first a primes.

This is sometimes called a “partial sieve function” or “Legendre-sum”.

EXAMPLES:

>>> from primecountpy.primecount import phi

>>> phi(1000, 3) == 266
True
>>> phi(2**30, 100) == 95446716
True
primecountpy.primecount.prime_pi(n, method=None)

Return the number of prime numbers smaller or equal than n.

INPUT:

  • n - an integer

EXAMPLES:

>>> from primecountpy.primecount import prime_pi
>>> prime_pi(1000) == 168
True

method has no effect, retained for compatibility:

>>> prime_pi(1000, method='deleglise_rivat') == 168
True
primecountpy.primecount.prime_pi_128(n)

Return the number of prime number smaller than n.

EXAMPLES:

>>> from primecountpy.primecount import prime_pi_128

>>> prime_pi_128(1000)
168
>>> prime_pi_128(10**10)
455052511

Functions

nth_prime(n)

Return the n-th prime integer.

phi(x, a)

Return the number of integers smaller or equal than x by any of the first a primes.

prime_pi(n[, method])

Return the number of prime numbers smaller or equal than n.

prime_pi_128(n)

Return the number of prime number smaller than n.