Count integers from a given range with no odd divisors | Function to count integers in the range 1 to N having no odd divisors ; Traverse the array ; Stores the nearest power of two less than arr [ i ] ; Stores the count of integers with no odd divisor for each query ; Iterate until powerOfTwo is less then or equal to arr [ i ] ; Print the answer for the current element ; Given array ; Size of the array
function oddDivisors ( arr , N ) { for ( i = 0 ; i < N ; i ++ ) { var powerOfTwo = 2 ; var count = 0 ; while ( powerOfTwo <= arr [ i ] ) { count ++ ; powerOfTwo = 2 * powerOfTwo ; } document . write ( count + " " ) ; } return ; } var arr = [ 15 , 16 , 20 , 35 ] ; var N = arr . length ; oddDivisors ( arr , N ) ;