Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For two random $d$ digit integers $a,b$, what is the probability $\gcd(a,b)<B$? Here $B$ is much much smaller than $a,b$.

share|cite|improve this question
up vote 6 down vote accepted

The probability that two integers, chosen uniformly at random from $1,2,\dots,n$, have greatest common divisor $g$, is (for large $n$) $\displaystyle{6\over\pi^2g^2}$. So the probability that the gcd is less than $B$ is $\displaystyle{6\over\pi^2}\sum_{g=1}^{B-1}{1\over g^2}$.

A reference is J. Chidambaraswamy and R. Sitarmachandrarao, On the probability that the values of $m$ polynomials have a given g.c.d., Journal of Number Theory 26 (1987) 237–245.

Information found at

There is a good exposition at

Choosing from $1,2,\dots,n$ isn't quite the same as choosing among $d$-digit numbers, but I suspect that for large $d$ the answers come out the same.

share|cite|improve this answer

Heuristically: For $k>B$, the probability that both $a$ is a multiple of $k$ is essentially $\frac1k$, hence that both $a$ and $b$ are multiples of $k$ it is $\frac1{k^2}$. Naively assuming independence (which gives an upper bound), the probability that $\gcd(a,b)>B$ is therefore at most $\le \sum_{k=B}^\infty \frac1{k^2}=\frac{\pi^2}6-\sum_{k=1}^B\frac1{k^2}$. For small $B$ this estimate is not very good.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.