6/ still blows my mind

there's an identity that still amazes me every time i see it.

P(gcd(a, b) = 1) = 6/π² (approx. 0.607927)

where this probability is defined via the limit of the proportion of coprime pairs in {1, ..., N}² as N → ∞.

one heuristic for why this is true is surprisingly elegant.

for any prime p,

P(p divides both a and b) = 1/p²

so

P(p does not divide gcd(a, b)) = 1 − 1/p²

which suggests

P(gcd(a, b) = 1) = ∏ₚ (1 − 1/p²)

now euler's product formula tells us:

ζ(s) = ∏ₚ 1/(1 − p⁻ˢ)

so at s = 2

∏ₚ (1 − 1/p²) = 1/ζ(2)

and since

ζ(2) = 1 + 1/2² + 1/3² + 1/4² + ... = π²/6

we get

P(gcd(a, b) = 1) = 6/π² (approx. 0.607927)

my favorite part isn't actually the probability

it's the geometric interpretation

a lattice point (a, b) is visible from the origin if and only if

gcd(a, b) = 1

because otherwise another lattice point lies on the same line segment and blocks the view.

therefore,

density of visible lattice points = 6/π²

i still find it remarkable that the same constant simultaneously connects
- prime factorization
- the riemann zeta function
- analytic number theory
- and a purely geometric notion of visibility on the integer lattice

---

edit: corrected the wording about choosing integers "uniformly at random." thanks to those who pointed it out.

Author: No-Artichoke9490