Search code examples
pari

Prime counting function in Pari GP


The prime counting function pi(x) computes the number of primes less than x. With Pari being well oriented towards working with prime numbers, I thought this function would be implemented, but I did not find anything in the documentation.

  • Is pi(x) already implemented in Pari GP?
  • If not, is it possible to find the index of a prime? I know the command prime(n) returns the n'th prime? (If it is possible to find this quickly then this combined with precprime could do the trick.)

Solution

  • It is primepi, as in:

    primepi(10^6)
    

    (returns 78498)