You are given a whole number n. Split it into at least two positive whole numbers that add up to n.
Multiply the parts together. For example, if n = 7, then 3 + 4 gives the product 12, and 2 + 2 + 3 gives the product 12 too.
Try all the ways to split and return the largest product you can get.
Examples
Example 1:
Input: n = 9
Output: 27
Explanation: 9 = 3 + 3 + 3, and the product is 27.
Example 2:
Input: n = 8
Output: 18
Explanation: 8 = 3 + 3 + 2, and 3 x 3 x 2 = 18.
Example 3:
Input: n = 12
Output: 81
Explanation: 12 = 3 + 3 + 3 + 3, and the product is 81.