Minimum operations required to make all elements in an array of first N odd numbers equal | Function to find the minimum number of operations required to make the array elements equal ; If the value of N is even ; Return the value ; Otherwise , N is odd ; Return the value ; Driver Code
function minOperation ( N ) { if ( N % 2 == 0 ) { return ( N / 2 ) * ( N / 2 ) ; } let k = ( N - 1 ) / 2 ; return k * ( k + 1 ) ; } let N = 6 ; document . write ( minOperation ( N ) ) ;