text: Smallest number exceeding N whose Kth bit is set | C # program for the above approach ; Function to find the number greater than n whose Kth bit is set ; Iterate from N + 1 ; Check if Kth bit is set or not ; Increment M for next number ; Return the minimum value ; Driver Code ; Given N and K ; Function Call
code: using System ; class GFG { static int find_next ( int n , int k ) { int M = n + 1 ; while ( true ) { if ( ( M & ( 1L << k ) ) > 0 ) break ; M ++ ; } return M ; } public static void Main ( String [ ] args ) { int N = 15 , K = 2 ; Console . Write ( find_next ( N , K ) ) ; } }