Count total set bits in all numbers from range L to R | Function to count set bit in [ L , R ] ; Variable for count set bit in range ; Count set bit for all number in range ; Use inbuilt function ; Given range L and R ; Function Call
function countSetBits ( L , R ) { let count = 0 ; for ( let i = L ; i <= R ; i ++ ) { count = Number ( i . toString ( ) . split ( " " ) . sort ( ) ) ; } return count ; } let L = 3 , R = 5 ; document . write ( " " + countSetBits ( L , R ) ) ;