Project Euler Lab - Problem 183

#183 - Maximum Product of Parts

● AppliedOfficial difficulty: 23%Maximize/minimize an objectiveTier B - browser, with the efficient algorithmNot viewed
↖ Euler Lab

Let \(N\) be a positive integer and let \(N\) be split into \(k\) equal parts, \(r = N/k\), so that \(N = r + r + \cdots + r\).
Let \(P\) be the product of these parts, \(P = r \times r \times \cdots \times r = r^k\).

For example, if \(11\) is split into five equal parts, \(11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2\), then \(P = 2.2^5 = 51.53632\).

Let \(M(N) = P_{\mathrm{max}}\) for a given value of \(N\).

It turns out that the maximum for \(N = 11\) is found by splitting eleven into four equal parts which leads to \(P_{\mathrm{max}} = (11/4)^4\); that is, \(M(11) = 14641/256 = 57.19140625\), which is a terminating decimal.

However, for \(N = 8\) the maximum is achieved by splitting it into three equal parts, so \(M(8) = 512/27\), which is a non-terminating decimal.

Let \(D(N) = N\) if \(M(N)\) is a non-terminating decimal and \(D(N) = -N\) if \(M(N)\) is a terminating decimal.

For example, \(\sum\limits_{N = 5}^{100} D(N)\) is \(2438\).

Find \(\sum\limits_{N = 5}^{10000} D(N)\).

This problem is taken from Project Euler, Problem 183.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=183. Published Friday, 22nd February 2008, 05:00 pm. Solved by 5,358 members at time of mirroring.

Why this is useful

Optimization. A genuine objective is optimised over a choice set - the same shape as calibration and optimal-execution problems (Phases 10, 16).

We classify relevance honestly - not every Euler problem is a trading application.

Learning mode

Pick how much scaffolding you want. Your choice is remembered per problem.

Scratchpad

Mathematical notes, formulas, pseudocode, hypotheses, complexity notes. Saved automatically with your progress.

Python workbench

Tier B - browser, with the efficient algorithm
Runs in the browser only with the intended efficient algorithm; a naive loop will hit the timeout.

Real Python (Pyodide) in a sandboxed Web Worker - no network, no filesystem, no DOM access. Ctrl/Cmd+Enter runs. Escape leaves the editor. Stop terminates the worker.

Python runtime not loaded (it boots on first run - a one-time local load).

Check your answer

Answers are checked against a salted hash held in a separate file - not printed in this page. This prevents accidental spoilers; it is not cryptographic protection (see the build notes).

Progressive hints

Confidence

Low confidence schedules this problem for spaced review, even if you solved it.

Reference solution

Spoiler
The complete original explanation (interpretation, naive approach, insight, proof, complexity, Python implementation, tests, common mistakes, alternatives) is hidden and lazy-loaded. Reveal it only after a meaningful attempt - the struggle is where the learning happens.