human
Count smaller numbers whose XOR with n produces greater value | Python program to count numbers whose XOR with n produces a value more than n ..
Position of current bit in n.
Traverse bits from LSB to MSB.
Initialize result.
If current bit is 0 , then there are 2 ^ k numbers with current bit 1 and whose XOR with n produces greater value.
Increase position for next bit.
Reduce n to find next bit.
Driver code"
Solution in Python:
assistant
#Here is code to count smaller numbers whose XOR with n produces greater value and the other steps required.
 def countNumbers ( n ) :
	k = 0
	count = 0
	while ( n > 0 ) :
		if ( ( n & 1 ) == 0 ) :
			count += pow ( 2 , k )
		k += 1
		n >>= 1
	return count
n = 11
print ( countNumbers ( n ) )