Minimum numbers needed to express every integer below N as a sum | C # program to find count of integers needed to express all numbers from 1 to N ; function to count length of binary expression of n ; Driver code
using System ; class GFG { static int countBits ( int n ) { int count = 0 ; while ( n > 0 ) { count ++ ; n >>= 1 ; } return count ; } static public void Main ( ) { int n = 32 ; Console . WriteLine ( " Minimum ▁ value ▁ of ▁ K ▁ is ▁ = ▁ " + countBits ( n ) ) ; } }