human
Check whether the number has only first and last bits set | Set 2 | function to check whether the number has only first and last bits set.
Driver Code"
Solution in Python:
 Can you provide a code to check whether the number has only first and last bits set and the other steps required?
assistant
#Here is code to check whether the number has only first and last bits set and the other steps required.
 def onlyFirstAndLastAreSet ( n ) :
	if ( n == 1 ) :
		return True
	if ( n == 2 ) :
		return False
	return ( ( ( n - 1 ) & ( n - 2 ) ) == 0 )
n = 9
if ( onlyFirstAndLastAreSet ( n ) ) :
	print ( " Yes " )
else :
	print ( " No " )