Number of prime numbers in a range Is there any function to evaluate the number of prime numbers between [2, n]?
For example, consider the following range: [2, 20]. In this case the number of prime numbers between 2 and 20 is 8: 2, 3, 5, 7, 11, 13, 17, 19.
Therefore the function I'm looking for would return 8.
Also, is there any function to evaluate the number of prime numbers between [x, y]?
 A: There are some formulas but the best we have so far is only asymptotic estimates.   
It is shown that if we denote with $\pi(n)$ the number of primes that do not exceed $n$ then the fraction
$$\frac{\pi(n)lnn}{n}$$ can be arbitrarily close to $1$.
This is the famous prime number theorem.
A: Number of primes between $[1,n]$ can be evaluate with $\frac{n}{\ln n}$
Number of primes between $[x,y]$ can be evaluate with $\frac{y}{\ln y}-\frac{x}{\ln x}$
A: For a reasonably fast method (substantially faster than finding all the primes) thanks to Meissel, Lehmer, Lagarias, Miller (who I saw posting on math.stackexchange recently) and Odlyzko, see
http://www.ams.org/journals/mcom/1996-65-213/S0025-5718-96-00674-6/S0025-5718-96-00674-6.pdf
For a not quite so fast but easier method by Legendre see
http://programmingpraxis.com/2011/07/22/counting-primes-using-legendres-formula/
Usually the function denoting the number of primes <= n is denoted as π (n). The number of primes in the interval [x, y] with x <= y is obviously π (y) - π (x - 1). 
