Count of numbers in range [ L , R ] with LSB as 0 in their Binary representation | C ++ implementation of the approach ; Function to return the count of required numbers ; Count of numbers in range which are divisible by 2 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countNumbers ( int l , int r ) { return ( ( r / 2 ) - ( l - 1 ) / 2 ) ; } int main ( ) { int l = 10 , r = 20 ; cout << countNumbers ( l , r ) ; return 0 ; }