Position of rightmost set bit | C # program to find the first rightmost set bit using XOR operator ; function to find the rightmost set bit ; Position variable initialize with 1 m variable is used to check the set bit ; left shift ; Driver Code ; function call
using System ; class GFG { static int PositionRightmostSetbit ( int n ) { int position = 1 ; int m = 1 ; while ( ( n & m ) == 0 ) { m = m << 1 ; position ++ ; } return position ; } static public void Main ( ) { int n = 16 ; Console . WriteLine ( PositionRightmostSetbit ( n ) ) ; } }