Number with set bits only between L | Function to return the integer with all the bits set in range L - R ; Driver Code
function setbitsfromLtoR ( L , R ) { return ( 1 << ( R + 1 ) ) - ( 1 << L ) ; } var L = 2 , R = 5 ; document . write ( setbitsfromLtoR ( L , R ) ) ;