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 ; Driver Code ; Given array ; Size of the array
def oddDivisors ( arr , N ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT powerOfTwo = 2 ; NEW_LINE count = 0 ; NEW_LINE while ( powerOfTwo <= arr [ i ] ) : NEW_LINE INDENT count += 1 ; NEW_LINE powerOfTwo = 2 * powerOfTwo ; NEW_LINE DEDENT print ( count , end = " ▁ " ) ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 15 , 16 , 20 , 35 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE oddDivisors ( arr , N ) ; NEW_LINE DEDENT