<s>[INST] How come, in this problem, the maximum product is always achieved using only $2$s and $3$s? Consider the following problem.
Given a number $N$, write it as a sum $n = n_1 + n_2 + \cdots + n_k$, such that the product $p = n_1 \times n_2 \times \cdots \times n_k$ is maximized.
For example, $11$ can be written as $2 + 3 + 3 + 3$ or as $7 + 4$, yielding the products $2 \times 3 \times 3 \times 3 = 54$ and $7 \times 4 = 28$.
So in this case, the answer is is $2\times 3\times 3\times 3$.
For $17$ we have the same situation: $2 \times 3 \times 3 \times 3 \times 3 \times 3 = 486$.
So my question is, why is the maximum product always achieved by using only $2$s and $3$s?
 [/INST] For every sequence of natural numbers $\{a_1,\dots,a_n\}$ such that $N=\sum\limits_{k=1}^{n}a_k$:


*

*If $a_k=4$, then you can get an equivalent value by decomposing it into $2+2$ since $2\cdot2=4$

*If $a_k=5$, then you can get a better value by decomposing it into $2+3$ since $2\cdot3=6>5$

*If $a_k=6$, then you can get a better value by decomposing it into $3+3$ since $3\cdot3=9>6$

*If $a_k>6$, then you can get a better value by decomposing it into one of the previous values

In addition to that, you can get a better value by replacing every triplet $\{2,2,2\}$ with a pair $\{3,3\}$:


*

*$2+2+2=6=3+3$

*$2\cdot2\cdot2=8<9=3\cdot3$



Hence the best decomposition is into a list of $2$s and $3$s, with at most two $2$s.
</s>