human
What is a code to length of the Longest Consecutive 1 s in Binary Representation and the other steps required given the following:
Length of the Longest Consecutive 1 s in Binary Representation | Function to find length of the longest consecutive 1 s in binary representation of a number.
Initialize result.
Count the number of iterations to reach x = 0..
This operation reduces length of every sequence of 1 s by one ..
Driver code"
How can the above be solved in Python?
assistant
#Here is code to length of the Longest Consecutive 1 s in Binary Representation and the other steps required.
 def maxConsecutiveOnes ( x ) :
	count = 0
	while ( x != 0 ) :
		x = ( x & ( x << 1 ) )
		count = count + 1
	return count
print ( maxConsecutiveOnes ( 14 ) )
print ( maxConsecutiveOnes ( 222 ) )