human
Program to find the Nth natural number with exactly two bits set | Function to find the Nth number with exactly two bits set.
Keep incrementing until we reach the partition of ' N ' stored in bit_L.
set the rightmost bit based on bit_R.
Driver code"
Solution in Python:
assistant
#Here is code to program to find the Nth natural number with exactly two bits set and the other steps required.
 def findNthNum ( N ) :
	bit_L = 1 ;
	last_num = 0 ;
	while ( bit_L * ( bit_L + 1 ) / 2 < N ) :
		last_num = last_num + bit_L ;
		bit_L += 1 ;
	bit_R = N - last_num - 1 ;
	print ( ( 1 << bit_L ) + ( 1 << bit_R ) ) ;
if __name__ == ' _ _ main _ _ ' :
	N = 13 ;
	findNthNum ( N ) ;