function to find the position of rightmost set bit . Returns - 1 if there are no set bits
static int getFirstSetBitPos ( int n ) { return ( ( int ) ( Math . Log ( n & - n ) / Math . Log ( 2 ) ) + 1 ) - 1 ; }