Minimum count of Full Binary Trees such that the count of leaves is N | C # implementation of the approach ; Function to return the minimum count of trees required ; To store the count of set bits in n ; Driver code
using System ; class GFG { static int minTrees ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } public static void Main ( ) { int n = 7 ; Console . Write ( minTrees ( n ) ) ; } }