# The probability that two integers picked at random are Prime.

To see for myself, I ran 100,000,000 random tests of $$gcd(m=random(), n=random())$$ (random max 32767) and the probability was 60.09% (approx $$\dfrac{6}{\pi^2}$$).

Also ran a similar test that accepts two "random" integers, then tallies any prime pairs it encounters and the probability was 1.15% (approx $$\dfrac{0.11}{\pi^2}$$).

Question, is there a known approximation for primes as there is for coprimes?

Just curious.

Thanks.

EDIT

Based upon the comments, "Randomly chosen positive integers less than $$n$$ would be fine." I'll try playing with increasing values of $$n$$ (currently set to $$32767$$) to see how it tends to $$0$$ as $$n$$ tends to infinity. Thanks!

• en.wikipedia.org/wiki/Prime_number_theorem Jan 24, 2021 at 22:38
• That said, "randomly chosen integers" doesn't make sense by itself. "Randomly chosen positive integers less than $n$" would be fine. You are able to uniformly at random select a positive integer less than $n$. You could also talk about the limiting behavior of such a probability as you take the limit as $n\to\infty$. There does not exist a uniform distribution over a countably infinite set however so you may not "pick an integer uniformly at random". Jan 24, 2021 at 22:40
• Interesting this $\frac{11}{\pi^2}$, but what is the definition of the function "primes(rand(),rand())" ?
– NN2
Jan 24, 2021 at 23:15
• It's a function that accepts two "random" integers, then tallies any prime pairs it encounters. Jan 24, 2021 at 23:34
• I assume that $1.150655$ is, like $60.099903$, a percentage. In which case, it's not actually $\frac{11}{\pi^2}$ but closer to $\frac{0.11}{\pi^2}$, which is reasonable for something that, in reality, is supposed to be tending to $0$ for a large range. Jan 25, 2021 at 0:24

It is a nontrivial thing to define a good idea of "randomly chosen integer", as @JMoravitz notes. The normal way to do this is to definite the density of a subset $$S \subset \mathbb{Z}_{\geq 1}$$ as $$\lim_{N \to \infty} \frac{ \#(S \cap \{n | 1\leq n \leq N \} ) }{N}$$
With this idea in mind, the only thing to do is recall the prime number theorem that $$\pi(N) \sim N/\log(N)$$ (i.e., $$\pi(N) = N/\log(N) + O(N)$$ ) where $$\pi$$ is the prime counting function. Then we have the density of prime numbers is $$\lim_{N \to \infty} \pi(N)/N$$ which tends to $$1/\log(N)$$ which tends to zero, as $$N \to \infty$$.