Minimum numbers needed to express every integer below N as a sum | Function to count length of binary expression of n ; Driver code
function countBits ( n ) { var count = 0 ; while ( n ) { count ++ ; n >>= 1 ; } return count ; } var n = 32 ; document . write ( " " + countBits ( n ) ) ;