Minimum count of consecutive integers till N whose bitwise AND is 0 with N | Function to count the minimum count of integers such that bitwise AND of that many consecutive elements is equal to 0 ; Stores the binary representation of N ; Stores the MSB bit ; Stores the count of numbers ; Return res ; Given Input ; Function Call
function count ( N ) { var a = N . toString ( 2 ) ; var m = a . length - 1 ; var res = N - ( Math . pow ( 2 , m ) - 1 ) ; return res ; } var N = 18 ; document . write ( count ( N ) ) ;