text: Smallest number exceeding N whose Kth bit is set | 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 ; Given N and K ; Function Call
code: function find_next ( n , k ) { let M = n + 1 ; while ( true ) { if ( ( M & ( 1 << k ) ) > 0 ) break ; M ++ ; } return M ; } let N = 15 , K = 2 ; document . write ( find_next ( N , K ) ) ;