Project Euler Lab - Problem 374

#374 - Maximum Integer Partition Product

● AdvancedOfficial difficulty: 47%DivisibilityTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

An integer partition of a number \(n\) is a way of writing \(n\) as a sum of positive integers.

Partitions that differ only in the order of their summands are considered the same. A partition of \(n\) into distinct parts is a partition of \(n\) in which every part occurs at most once.

The partitions of \(5\) into distinct parts are:
\(5\), \(4+1\) and \(3+2\).

Let \(f(n)\) be the maximum product of the parts of any such partition of \(n\) into distinct parts and let \(m(n)\) be the number of elements of any such partition of \(n\) with that product.

So \(f(5)=6\) and \(m(5)=2\).

For \(n=10\) the partition with the largest product is \(10=2+3+5\), which gives \(f(10)=30\) and \(m(10)=3\).
And their product, \(f(10) \cdot m(10) = 30 \cdot 3 = 90\).

It can be verified that
\(\sum f(n) \cdot m(n)\) for \(1 \le n \le 100 = 1683550844462\).

Find \(\sum f(n) \cdot m(n)\) for \(1 \le n \le 10^{14}\).
Give your answer modulo \(982451653\), the \(50\) millionth prime.

This problem is taken from Project Euler, Problem 374.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=374. Published Saturday, 3rd March 2012, 07:00 pm. Solved by 806 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 C - reduced scale in browser; full scale in notebook
Browser runs a reduced, clearly-labelled educational scale; the original scale is provided in a local notebook.

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.