human
Print first n numbers with exactly two set bits | Prints first n numbers with two set bits.
Initialize higher of two sets bits.
Keep reducing n for every number with two set bits ..
Consider all lower set bits for current higher set bit.
Print current number.
If we have found n numbers.
Consider next lower bit for current higher bit ..
Increment higher set bit.
Driver code"
Solution in Python:
 What is a code to print first n numbers with exactly two set bits and the other steps required?
assistant
#Here is code to print first n numbers with exactly two set bits and the other steps required.
 def printTwoSetBitNums ( n ) :
	x = 1
	while ( n > 0 ) :
		y = 0
		while ( y < x ) :
			print ( ( 1 << x ) + ( 1 << y ) , end = " ▁ " )
			n -= 1
			if ( n == 0 ) :
				return
			y += 1
		x += 1
printTwoSetBitNums ( 4 )