Given an integer n, break it into the sum of k positive integers, where k &gt;= 2, and maximize the product of those integers.

Return the maximum product you can get.

&nbsp;
Example 1:

Input: n = 2
Output: 1
Explanation: 2 = 1 + 1, 1 × 1 = 1.


Example 2:

Input: n = 10
Output: 36
Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36.


&nbsp;
Constraints:


	2 &lt;= n &lt;= 58


class Solution:
    def integerBreak(self, n: int) -> int:
        dp = [0 for _ in range(n+1)]
        dp[1] = 1
        for i in range(2, n+1):
            for j in range(1, i//2+1):
                dp[i] = max(j * (i-j), j * dp[i-j], dp[i])
        return dp[-1]
class Solution {
    public int integerBreak(int n) {
        //dp array: maximum product of splitling int i
        int[] dp = new int[n + 1];
        
        // traverse
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= i / 2; j++) {
                 dp[i] = Math.max(Math.max(j * (i - j), j * dp[i - j]), dp[i]);
            }
        }
        return dp[n];
    }
}
class Solution
{
public:
    int integerBreak(int n)
    {
        if (n == 2)
            return 1;
        if (n == 3)
            return 2;
        if (n == 4)
            return 4;
        int k = n / 3;
        int m = n % 3;
        int ans;
        if (m == 0)
            ans = pow(3, k);
        else if (m == 1)
            ans = pow(3, k - 1) * 4;
        else if (m == 2)
            ans = pow(3, k) * m;
        return ans;
    }
};
var integerBreak = function(n) {

       if(n == 2) return 1;
       if(n == 3) return 2;
       if(n == 4) return 4;

       let c = ~~(n/3);
       let d = n % 3;

       if(d === 0){
           return 3 ** c;
       }

       if(d === 1){
           return 3 ** (c-1) * 4;
       }

       if(d === 2){
           return 3 ** (c) * 2;
       }

};
Integer Break