Maximum Product Cutting | DP | The main function that returns maximum product obtainable from a rope of length n ; Base cases ; Make a cut at different places and take the maximum of all ; Return the maximum of all values ; Driver program to test above functions
function maxProd ( n ) { if ( n == 0 n == 1 ) return 0 ; let max_val = 0 ; for ( let i = 1 ; i < n ; i ++ ) { max_val = Math . max ( max_val , Math . max ( i * ( n - i ) , maxProd ( n - i ) * i ) ) ; } return max_val ; } document . write ( " " + maxProd ( 10 ) ) ;