# Probability that a number picked randomly is prime

There is some strange thing about the probability for a randomly chosen number to be prime. That probability is $$\frac{\pi(n)}{n}$$. Here is what disturb me: $$\frac{\pi(n)}{n}=\frac{1}{\log{n}}+O(\frac{1}{\log^2(n)})$$ which mean that when n is sufficiently large that probability vanishes, intuitively that is wrong. The other interpretation is the number of prime is very smaller than the number of integers, which seems to be correct. Since they are both infinite why the limit goes to $$0$$. For exemple the average number of odd integers is $$0.5$$, and I haven’t seen any infinite subset of $$\mathbb{N}$$ with 0 as average value.

Point1: Is there a another interpretation of this vanishing probability?

Point2: Are there other subset $$A_n\in \mathbb{N}$$ for which $$\frac{|A_n|}{ |\mathbb{N}|} \rightarrow 0$$?

• Regarding your last sentence, what about the subset $\{ 1,2,4,8,16,32,64,\ldots\}$ (powers of $2$)? – Minus One-Twelfth Mar 20 at 22:33
• I don't see how that is intuitively wrong, though... It makes sense that as your $n$ grows, the probability of an average number being prime goes to $0$. Why do you think projects like PrimeGrid have such a hard time finding new primes? – Peiffap Mar 20 at 22:36
• @MinusOne-Twelfth: It seems that a power of 2 is more rare than a prime number? Is that correct? – HAMIDINE SOUMARE Mar 20 at 22:41
• "The other interpretation is the number of prime is very [much] smaller than the number of integers, which seems to be correct." Primes are a subset of the positive integers, but don't both sets have cardinality $\aleph_0?$ // What is your probability measure on the positive integers? // Can you explain what it means to sample a positive integer at random? – BruceET Mar 20 at 23:06
• @Peiffap: Rubbish! Bertrand's postulate tells us that prime numbers are at least as common as powers of two; and the Prime Number Theorem tells us that in fact they are significantly more common. – TonyK Mar 20 at 23:10

## Point 1

The interpretation is simply what you said: as $$n$$ grows, it becomes increasingly rare for $$n$$ to be prime. As a proof'' of this, you can look at the PrimeGrid project, for example. They spend years of computing time scanning insane amounts of huge numbers, but only rarely find primes.

## Point 2

As mentioned by @Minus One-Twelfth, the subset of powers of two (or of any integer, really), $$\{1, 2, 4, 8, 16, 32, 64, \ldots\}$$ is another subset for which the probability of randomly picking one goes to $$0$$ as $$n$$ grows.

## Edit

A good point raised by @BruceET in the comments is that as usual, when dealing with infinities, one needs to be very careful and rigorous in their definitions in order to avoid most paradoxes that can seemingly arise. Defining a probability measure on the natural numbers is not a straightforward task, as mentioned by @verret.

• As BruceET says, I think it should also be emphasised that it's not that straightforward to define a probability measure on the natural numbers, so statements about the probability have to be phrased and interpreted carefully. – verret Mar 21 at 0:56
• to actually understand how many primes are out there, a simple example as follows is illuminating: pick a random number of up to a 1000 decimal digits $1 \leq n < 10^{1000}$; then the probability that the number is prime is ~$\frac{1}{2300}$ which is $0.00043..$, the probability that the number is square is ~$\frac{1}{10^{500}}$ which is $0.000...1$ with 499 zeroes after the decimal point, and the probability that a number is a power of two is about a third of $\frac{1}{10^{996}}$ which is a third of $0.0000..1$ with 995 zeroes after the decimal point – Conrad Mar 21 at 16:01