Integer Break Calculator
Combinatorics
- The optimal split of 10 uses as many 3s as possible, because 3 is the integer nearest e.
- Decomposition used: 2 threes and one 4 (written as 2 + 2), and the parts sum back to 10.
- No 1s appear (they add nothing to a product), and a remainder of 1 is handled by merging two 3s into a 4.
- Maximum product = 36.
Break an integer into pieces and multiply the pieces: what split gives the biggest product? For 10, the answer is 3 + 3 + 4, giving 3 x 3 x 4 = 36 - better than 5 + 5 = 25, better than 2 + 2 + 2 + 2 + 2 = 32, better than any other split. This is the integer break problem, a staple of algorithm courses, and its solution has a memorably simple shape: use as many 3s as possible.
The reason is a calculus fact wearing a discrete disguise. For a part of size x, the 'efficiency' is x^(1/x) - the product contributed per unit of sum - and that function peaks at x = e. The integer nearest e is 3, so 3s are the most efficient parts; 2s are the acceptable filler; 1s are useless and never appear. The only subtlety is a remainder of 1, handled by merging it with a 3 to make a 4 (since 3 x 1 = 3 loses to 4, and 3 + 3 + 1 becomes 4 + 3).
Enter n from 2 to 100. The calculator returns the maximum product and the optimal decomposition: for 58, that is 18 threes and one 4, giving 4 x 3^18 = 1,549,681,956; for 100, 32 threes and one 4, giving 7,412,080,755,407,364.
Worked examples
Break 10
(10)
| Maximum product | 36 |
| Optimal parts | 2 threes and one 4 (written as 2 + 2) |
| Number of parts | 3 |
Break 58
(58)
| Maximum product | 1,549,681,956 |
| Optimal parts | 18 threes and one 4 (written as 2 + 2) |
| Number of parts | 19 |
Break 100
(100)
| Maximum product | 7,412,080,755,407,364 |
| Optimal parts | 32 threes and one 4 (written as 2 + 2) |
| Number of parts | 33 |
Why 3 is optimal
Compare the candidates head to head. A 4 splits as 2 + 2 with product 4 - equal, so 4s and pairs of 2s are interchangeable. A 5 is beaten by 3 + 2 (6 > 5). A 6 by 3 + 3 (9 > 6). Every integer from 4 up is improved or matched by splitting it into 3s and 2s, which proves no optimal split contains a part of 5 or more, and the rest is bookkeeping about remainders.
The e argument explains why this had to be true before the case analysis confirms it: continuous optimisation picks e ≈ 2.718, and the integer lattice rounds that verdict to 3. Problems where the continuous and discrete optima align this cleanly are rarer than they look, which is why integer break is such a satisfying teaching example.
The three remainder cases
If n mod 3 = 0, the split is all 3s: n = 9 gives 27, n = 12 gives 81. If n mod 3 = 2, the split is 3s plus a single 2: n = 11 gives 3 + 3 + 3 + 2 with product 54 - in formula, (n-2)/3 threes and one 2, product 2 x 3^((n-2)/3).
If n mod 3 = 1, two of the 3s must give up a unit each to form a 4 with the remainder: the split is (n-4)/3 threes and one 4, product 4 x 3^((n-4)/3). The cases n = 2 and n = 3 are degenerate (forced splits 1 + 1 and 1 + 2, products 1 and 2) because the problem demands at least two parts.
Worked examples
n = 10: since 10 mod 3 = 1, the rule gives (10-4)/3 = 2 threes and one 4 - the split 3 + 3 + 4 with product 36. n = 58: 58 mod 3 = 1, giving (58-4)/3 = 18 threes and one 4, product 4 x 3^18 = 4 x 387,420,489 = 1,549,681,956. n = 100: 32 threes and one 4, product 4 x 3^32 = 7,412,080,755,407,364.
These large products are computed exactly: 3^32 is about 1.85 x 10^15 and the final products stay below 2^53 ≈ 9.01 x 10^15, the ceiling for exact integer arithmetic in the browser - which is why the input range stops at 100 rather than, say, 110 (whose product would cross the line).
Dynamic programming versus the closed form
Integer break is usually taught as a dynamic programming exercise: dp[n] = max over j of j x dp[n-j], building up from small cases. The DP is O(n^2) and works without insight; the closed form is O(1) and is the insight. Verifying one against the other - as this page's development did for every n from 2 to 40 - is the right relationship between the two methods.
The DP also handles variants the closed form cannot: restricted part sets (only even parts, only primes), limited numbers of parts, or parts drawn from a finite menu. When a problem resists the all-3s pattern, DP is the fallback - and recognising which situation you are in is the actual skill.
Where integer break appears
The problem is a LeetCode classic (343) and a common interview question, but the underlying trade-off - many medium pieces beat few large ones when value multiplies - recurs in real settings: splitting a budget across multiplicative-return channels, segmenting a product of probabilities, even the theory of how organisms should divide reproductive effort across offspring of different sizes.
The continuous version (maximise the product of parts summing to S, with real parts) has the elegant answer that all parts should equal e and the number of parts should be S/e - one of the few places the number e walks out of pure mathematics uninvited and entirely welcome.
Edge cases and checks
n = 2 and n = 3 are forced: the 'at least two parts' rule leaves only 1 + 1 and 1 + 2, products 1 and 2 - worse than the unbroken number, which is the price of the rule. From n = 4 onwards splitting always wins or ties (4 = 2 + 2 ties at 4).
A useful self-check for any claimed answer: the parts must sum to n, contain no 1s, no part above 4, and at most two 2s (three 2s would merge into two 3s and gain: 8 < 9). The calculator's decompositions satisfy all four conditions by construction.
The sequence of answers
The maximum products run 1, 2, 4, 6, 9, 12, 18, 27, 36, 54, 81... (OEIS A000792), settling into a rhythm of multiplying by 3 every three steps, with the remainder cases inserting their factors of 2 and 4. After n = 10 or so the pattern is fully established and the sequence is purely the closed form unfolding.
That regularity makes integer break a good first example of a wider phenomenon: discrete optimisation problems whose answers become eventually periodic in structure once a dominant building block (here, the 3) takes over.
Integer break as a teaching example
Few contest problems repay study like this one, because it contains three complete solution styles in miniature. The greedy insight (all 3s, adjust the remainder) is a proof by exchange argument. The dynamic program is a five-line recurrence. And the closed form requires the number-theoretic observation that the pattern repeats every three integers - an eventual-periodicity phenomenon that recurs across discrete optimisation.
It is also an honest example of a problem whose continuous relaxation is exactly solvable (the e in the derivation is not decoration) yet whose integer answer needs genuine case work at the boundary - the n = 2, 3, 4 small cases and the remainder-1 adjustment. Problems that are easy in the limit and fiddly at the edges are most of applied mathematics; integer break is the friendliest possible introduction.
FAQs
What is the integer break of 10?
36 - split 10 as 3 + 3 + 4 (equivalently 3 + 3 + 2 + 2) and multiply.
Why are 3s optimal in integer break?
Because 3 is the integer closest to e, and parts of size e maximise a product for a fixed sum: x^(1/x) peaks at e.
How is a remainder of 1 handled?
Merge it with a 3 to form a 4: the split uses (n-4)/3 threes and one 4, since 4 beats 3 x 1.
What is the integer break of 100?
7,412,080,755,407,364 - the product of 32 threes and one 4.
Can the optimal split contain a 1?
Never - a 1 adds to the sum without multiplying the product. Only the forced cases n = 2 and n = 3 contain 1s.
Is integer break the same as integer partition?
No. Partitions count the ways to split n; integer break finds the split with the largest product.