Minimum number using set bits of a given number | An efficient Javascript program to find minimum number formed by bits of a given number . ; Returns minimum number formed by bits of a given number . ; _popcnt32 ( a ) gives number of 1 's present in binary  representation of a. ; Driver Code .
function _popcnt32 ( number ) { let count = 0 ; while ( number > 0 ) { count += number & 1 ; number >>= 1 ; } return count ; } function minimize ( a ) { let n = _popcnt32 ( a ) ; return ( Math . pow ( 2 , n ) - 1 ) ; } let a = 11 ; document . write ( minimize ( a ) ) ;