Product of all Subarrays of an Array | Set 2 | Function to find the product of elements of all subarray ; Initialize the result ; Computing the product of subarray using formula ; Return the product of all elements of each subarray ; Given array arr [ ] ; Function Call
def SubArrayProdct ( arr , n ) : NEW_LINE INDENT result = 1 ; NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT result *= pow ( arr [ i ] , ( i + 1 ) * ( n - i ) ) ; NEW_LINE DEDENT return result ; NEW_LINE DEDENT arr = [ 2 , 4 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE print ( SubArrayProdct ( arr , N ) ) NEW_LINE