Number with set bits only between L | Function to return the integer with all the bits set in range L - R ; Driver Code
< ? php function setbitsfromLtoR ( $ L , $ R ) { return ( 1 << ( $ R + 1 ) ) - ( 1 << $ L ) ; } $ L = 2 ; $ R = 5 ; echo setbitsfromLtoR ( $ L , $ R ) ; ? >