human
Toggle all bits after most significant bit | Function to toggle bits starting from MSB.
temporary variable to use XOR with one of a n.
Run loop until the only set bit in temp crosses MST of n ..
Toggle bit of n corresponding to current set bit in temp ..
Move set bit to next higher position ..
Driver code"
Solution in Python:
assistant
#Here is code to toggle all bits after most significant bit and the other steps required.
 def toggle ( n ) :
	temp = 1
	while ( temp <= n ) :
		n = n ^ temp
		temp = temp << 1
	return n
n = 10
n = toggle ( n )
print ( n )