Function to find the position of rightmost set bit
static int getPosOfRightmostSetBit ( int n ) { return ( int ) ( ( Math . Log10 ( n & - n ) ) / ( Math . Log10 ( 2 ) ) ) + 1 ; } static int setRightmostUnsetBit ( int n ) {