human
Find smallest value of K such that bitwise AND of numbers in range [ N , N | Function is to find the largest no which gives the sequence n & ( n - 1 ) & ( n - 2 ) & ... . . & ( n - k ) = 0..
Since , we need the largest no , we start from n itself , till 0.
Driver Code"
Solution in Python:
 ... Write me a code to find smallest value of K such that bitwise AND of numbers in range [ N , N and the other steps required?
assistant
#Here is code to find smallest value of K such that bitwise AND of numbers in range [ N , N and the other steps required.
 def findSmallestNumK ( n ) :
	cummAnd = n
	i = n - 1
	while ( cummAnd != 0 ) :
		cummAnd = cummAnd & i
		if ( cummAnd == 0 ) :
			return i
		i -= 1
	return - 1
if __name__ == ' _ _ main _ _ ' :
	N = 17
	lastNum = findSmallestNumK ( N ) ;
	K = lastNum if lastNum == - 1 else N - lastNum
	print ( K )