Count of numbers in range [ L , R ] with LSB as 0 in their Binary representation | Function to return the count of required numbers ; If rightmost bit is 0 ; Return the required count ; Driver code ; Call function countNumbers
def countNumbers ( l , r ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT if ( ( i & 1 ) == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT l = 10 NEW_LINE r = 20 NEW_LINE print ( countNumbers ( l , r ) ) NEW_LINE