Smallest number whose set bits are maximum in a given range | Returns smallest number whose set bits are maximum in given range . ; Driver code
< ? php function countMaxSetBits ( $ left , $ right ) { while ( ( $ left | ( $ left + 1 ) ) <= $ right ) $ left |= $ left + 1 ; return $ left ; } $ l = 1 ; $ r = 5 ; echo countMaxSetBits ( $ l , $ r ) , " STRNEWLINE " ; $ l = 1 ; $ r = 10 ; echo countMaxSetBits ( $ l , $ r ) ; ? >