Minimum divide by 2 operations required to make GCD odd for given Array | Function to find the minimum number of operations to make the GCD of the array odd ; Stores the minimum operations required ; Stores the powers of two for the current array element ; Dividing by 2 ; Increment the count ; Update the minimum operation required ; Return the result required ; Driver Code
function minimumOperations ( arr , N ) { let mini = Number . MAX_SAFE_INTEGER ; for ( let i = 0 ; i < N ; i ++ ) { let count = 0 ; while ( arr [ i ] % 2 == 0 ) { arr [ i ] = Math . floor ( arr [ i ] / 2 ) ; count ++ ; } if ( mini > count ) { mini = count ; } } return mini ; } let arr = [ 4 , 6 ] ; let N = arr . length ; document . write ( minimumOperations ( arr , N ) ) ;