Minimize product of first 2 ^ Kâ €“ 1 Natural Numbers by swapping bits for any pair any number of times | Function to find the minimum positive product after swapping bits at the similar position for any two numbers ; Stores the resultant number ; range / 2 numbers will be 1 and range / 2 numbers will be range - 1 ; Multiply with the final number ; Return the answer ; Driver Code
function minimumPossibleProduct ( K ) { let res = 1 ; let range = ( 1 << K ) - 1 ; for ( let i = 0 ; i < K ; i ++ ) { res *= ( range - 1 ) ; } res *= range ; return res ; } let K = 3 ; document . write ( minimumPossibleProduct ( K ) ) ;