Count numbers from a given range having same first and last digits in their binary representation | Java program to implement the above approach ; Function to count numbers in range [ L , R ] having same first and last digit in the binary representation ; Driver code ; Given range [ L , R ] ; Function Call
import java . util . * ; class GFG { static void Count_numbers ( int L , int R ) { int count = ( R - L ) / 2 ; if ( R % 2 != 0 L % 2 != 0 ) count += 1 ; System . out . print ( count ) ; } public static void main ( String [ ] args ) { int L = 6 , R = 30 ; Count_numbers ( L , R ) ; } }