# Frequency of the Prime Numbers

Suppose I took all natural numbers less than or equal to $x$ and I picked one at random. Is there a way that we know of to express the probability that my number is prime in terms of $x$, for all $x$?

For example, for $x=12$, the prime numbers less than or equal to $x$ are $2,3,5,7$ and $11$, so my probability is $5/12$.

## 1 Answer

There is no explicit formula, but the prime number theorem says that as $x$ tends to infinity, there are around $\frac{x}{\ln x}$ primes $≤ x$.

This means that the chance that a random number is prime will be around $\frac{x}{\ln x} \cdot \frac{1}{x} = \frac{1}{\ln x}$.

• In OPs example, 1/ln(12) = 0.40 while 5/12 = 0.42. Aug 8, 2018 at 12:34
• infinity is a bit further Aug 8, 2018 at 12:35
• @infinitezero The formula is not exact – I said the chance will be around that number. (By the way, this answer is blowing up!) Aug 8, 2018 at 12:36
• I know. I just pointed out that even for small X it's pretty close. Aug 8, 2018 at 12:37
• $\frac{1}{\ln x}$ is the chance that a random number selected from the set $\{1,...,x\}$ will be prime. Aug 8, 2018 at 13:22