In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more integers (at least one of which is not zero), is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.
Given an integer N. Now Find how many GCD(A,B)=B Where 1≤A≤B≤N For example,for N=3 the result will be 5.It can be found in the following way.
GCD(1,1)=1 OK
GCD(1,2)=1
GCD(1,3)=1
GCD(2,1)=1 OK
GCD(2,2)=2 OK
GCD(2,3)=2
GCD(3,1)=1 OK
GCD(3,2)=1
GCD(3,3)=3 OK
Here we get 5 combination where GCD(A,B)=B But how can I calculate it for 1≤N≤10^9 efficiently?
gdc(a,b)==b
iffb*n=a
forn
inN
andb<=a
$\endgroup$