Integer Break

Medium

Break n into the sum of at least two positive integers and return the maximum product of those parts.

Example 1

integerBreak()
Input
n = 2
Output
1

Why

2 = 1 + 1, product 1

Example 2

integerBreak()
Input
n = 10
Output
36

Why

10 = 3 + 3 + 4, product 36
Constraints
2 <= n <= 58

Topics

MathDynamic Programming

Implement integerBreak in the editor and return the answer — printing it is never graded.