# maximum product of n positive integers whose sum is k [closed]

We have to find n numbers such that $$x_1 + x_2 + \cdots + x_n = k$$ $$x_1 * x_2 * .....* x_n = maximum$$

What are the values of $$x_1, x_2...x_n$$ ?

Note that $$x_1, x_2...x_n$$ are all positive integers .

P.S : I had posted a similar question before. In that question, $$x_1, x_2...x_n$$ could be any positive numbers and did not necessarily have to be integers. This is the previous question : maximum product of n numbers whose sum is k

• Can someone explain the downvotes please? Feb 5, 2021 at 15:45
• @riskymysteries I made a similar post before and people probably thought that this post and my post before are asking the same question ..here is the previous post : puzzling.stackexchange.com/questions/107082/… Feb 5, 2021 at 16:23

First suppose that the $$x_i$$ are restricted to non-negative integers. In this case we need the $$x_i$$ to be

all equal, or at least as close to equal as possible.

The reason is that

For any $$d>0$$ we have $$(t-d)(t+d) = t^2-d^2 < t\cdot t$$ and $$(t-d)(t+d+1) = t^2+t-d^2-d < t(t+1)$$ So if any two of the $$x_i$$ differ by 2 or more, increasing the smaller and decreasing the larger will increase their product.

So the values of $$x_i$$ are:

$$\lfloor \frac{k}{n}\rfloor$$ or $$\lceil \frac{k}{n}\rceil$$. There will be $$k \bmod n$$ of the latter.

Suppose now that the $$x_i$$ are allowed to be negative.

For $$n=1$$ or $$n=2$$ allowing negative values makes no difference, so this case is as above.

For $$n\ge 3$$ we can choose the following values for $$x_i$$:

The first three variables have values $$x_1=T+k+4-n$$, $$x_2=-T$$, $$x_3=-1$$, and the remaining $$n-3$$ variables all have value $$1$$. Here $$T$$ is an arbitrary value large enough to make $$x_1$$ positive. Their sum is $$k$$ as required, but their product can be made arbitrarily large by choosing $$T$$ larger.

• Funnily enough, your choices in the last paragraph are exactly the same as those I made on the other question, but in a different order. Feb 3, 2021 at 17:06
• @hexomino , I just realised that whether k is a positive number or k is a positive integer, in both the cases, xi= k/n . The same logic as those presented in the answers to the previous question : puzzling.stackexchange.com/questions/107082/… are applicable . Am I right ? Feb 3, 2021 at 18:35
• @HemantAgarwal integers are numbers so yes. Feb 3, 2021 at 18:36
• @hexomino , so there is nothing new to be gained from keeping this question up , right ? Feb 3, 2021 at 18:37
• @HemantAgarwal Correct. However, if I were you I would delete the third question you posted and edit this one to make x_i integers because Jaap has given a correct answer to that question and it seems unnecessary to make him write up the same thing somewhere else. Feb 3, 2021 at 18:41

The following answer was given by @GarethMcCaughan .

There is always an optimal answer with no two factors differing by more than 1, because if we have factors a,b with a>b+1 then replacing them with a−1,b+1 leaves the sum unaltered and yields a product that has increased by a−b−1≥0.

So

consider an optimal configuration with no two xj differing by more than 1. Letting x be the smallest of our factors, some of our n factors are x and the rest are x+1; let's say m of them are x+1 where 0≤m<n. (We can't have m=n because then the smallest number would actually be x+1.) Then the sum (which must equal k) is nx+m, so m=k mod n, and there is exactly one m with this property and 0≤m<n, namely the remainder on dividing k by n. So this configuration is unique (up to permutation of the xs).