Count numbers from a given range having same first and last digits in their binary representation | Function to count numbers in range [ L , R ] having same first and last digit in the binary representation ; Given range [ L , R ] ; Function Call
function Count_numbers ( L , R ) { var count = ( R - L ) / 2 ; if ( R % 2 != 0 L % 2 != 0 ) count += 1 ; document . write ( count ) ; } var L = 6 , R = 30 ; Count_numbers ( L , R ) ;