Integer Break

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
Inputn = 2
Output1
2 = 1 + 1, and 1 × 1 = 1.
Example 2
Inputn = 10
Output36
10 = 3 + 3 + 4, and 3 × 3 × 4 = 36.

Constraints

  • 2 <= n <= 58

Asked at 7 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate