human
Count of numbers having only 1 set bit in the range [ 0 , n ] | Function to return the required count.
To store the count of numbers.
Every power of 2 contains only 1 set bit.
Driver code"
Solution in Python:

=====
Give me a code to count of numbers having only 1 set bit in the range [ 0 , n ] and the other steps required?
assistant
#Here is code to count of numbers having only 1 set bit in the range [ 0 , n ] and the other steps required.
 def count ( n ) :
	cnt = 0
	p = 1
	while ( p <= n ) :
		cnt = cnt + 1
		p *= 2
	return cnt
n = 7
print ( count ( n ) ) ;