human
Count number of pairs ( A <= N , B <= N ) such that gcd ( A , B ) is B | returns number of valid pairs.
initialize k.
loop till imin <= n.
Initialize result.
max i with given k floor ( n / k ).
adding k * ( number of i with floor ( n / i ) = k to ans.
set imin = imax + 1 and k = n / imin.
Driver code"
How can the above be solved in Python?

=====
Give me a code to count number of pairs ( A <= N , B <= N ) such that gcd ( A , B ) is B and the other steps required?
assistant
#Here is code to count number of pairs ( A <= N , B <= N ) such that gcd ( A , B ) is B and the other steps required.
 def CountPairs ( n ) :
	k = n
	imin = 1
	ans = 0
	while ( imin <= n ) :
		imax = n / k
		ans += k * ( imax - imin + 1 )
		imin = imax + 1
		k = n / imin
	return ans
print ( CountPairs ( 1 ) )
print ( CountPairs ( 2 ) )
print ( CountPairs ( 3 ) )