Minimum number using set bits of a given number | An efficient C # 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 .
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static long minimize ( long a ) { string binaryString = Convert . ToString ( a , 2 ) ; int n = binaryString . Split ( new [ ] { '0' } , StringSplitOptions . RemoveEmptyEntries ) . Length + 1 ; return ( ( long ) Math . Pow ( 2 , n ) - 1 ) ; } static void Main ( ) { long a = 11 ; Console . Write ( minimize ( a ) ) ; } }