TITLE: What is the probability that GCD of $(a,b)$ is $b$?
QUESTION [9 upvotes]: My question is quite simple. I have been googling a lot lately trying to find a solution to this: 
Given a sequence of n integers $[1,2,...,n]$. If we pick two numbers randomly from the set say, a and b. The find the probability that GCD$(a,b)=b$? 
For example:
If $N=1$, the probability is $1/1$.
If $N=2$, probability is $3/4$ $[(1,1),(2,1),(2,2)$ satisfy out $of (1,1),(2,1),(2,2), (1,2)$ total cases]
If $N=3$, the probability is $5/9$.
My searches on google show me pages where : probability of GCD$(a,b)=1$ (relative co-prime) are calculated using the zeta function. I don't really know how to use that in this case !! Or whether if that is applicable here!!

REPLY [2 votes]: Note that if $(a,b)=b$ then $0\lt a=kb \le n$. The number of pairs $a,b$ with $(a,b)=b$ is therefore the same as the number of pairs $b,k$ with $0\lt kb \le n$.
This is the same as the number of integer points in the first quadrant between the axes $x=0$ and $y=0$ and the rectangular hyperbola $xy=n$ and this is also the sum of the arithmetical function $d(n)$ which is $$n\log n+(2\gamma-1)n+O(\sqrt n)$$
Divide this by the number of pairs to get the probability. Note that this includes the possibility $a=b$, which could easily be excluded if necessary. The precise calculation also depends on whether the order matters, but the principle is the same.