Count numbers from a given range having same first and last digits in their binary representation | C # 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
using System ; class GFG { static void Count_numbers ( int L , int R ) { int count = ( R - L ) / 2 ; if ( R % 2 != 0 L % 2 != 0 ) count += 1 ; Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int L = 6 , R = 30 ; Count_numbers ( L , R ) ; } }