TAOCP 4.5.2 Exercise 12

If $u$ and $v$ are random positive integers, let $d$ be a positive integer.

Section 4.5.2: The Greatest Common Divisor

Exercise 12. [**] [M24] (E. Cesàro.) If $u$ and $v$ are random positive integers, what is the average number of (positive) divisors they have in common? [Hint: See the identity in exercise 10(d), with $a_k = b_m = 1$.]

Verified: yes
Solve time: 1m07s


If $u$ and $v$ are random positive integers, let $d$ be a positive integer. The probability that $d$ divides both $u$ and $v$ is $1/d^2$, because $u$ and $v$ are independent and each is divisible by $d$ with probability $1/d$. Summing over all $d \ge 1$, the expected number of positive divisors common to $u$ and $v$ is therefore

$\sum_{d=1}^{\infty} \frac{1}{d^2} = \frac{\pi^2}{6},$

by the classical identity for the Riemann zeta function at $2$. This completes the proof.

The average number of positive divisors shared by two random positive integers is $\boxed{\pi^2/6}$.