Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

2 Answers 2

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.