The implemented algorithm is based in the fact that x/log(x) is asymptotically equal to Pi(x), also known as "Prime Number Theorem".
Closer approximations could be implemented by using the Logarithmic Integral Function. The function countprimes of the present package is another way to get a better approximation (in return for a less efficient computation) of Pi(x). Alhought the algorithm is not deterministic, it is based in the Miller-Rabin Probabilistic Primality Test, therefore the error can be arbitrarily reduced.