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 1


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}$.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .