# Leetcode 343 - Integer break

`Note`

:

`DP[i]`

is the maximum product of`i`

- The DP formula is
`DP[i] = Max(DP[i], j*(i-j), j*DP[i-j])`

. Note that we compare`DP[i]`

because when`i`

is fixed, we iterate through`j`

and we have to make sure that we always keep the biggest`DP[i]`

by comparing it with`j*(i-j)`

`j*DP[i-j]`

. - We have to prefill the result array with
`n+1`

`0`

otherwise it gives us`NaN`

because`Math.max(undefined, ...number)`

returns`NaN`

.

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

Return the maximum product you can get.

**Example:**

1 | Input: n = 2 |

1 | Input: n = 10 |

1 | /** |