Project Euler Lab - Problem 88

#88 - Product-sum Numbers

● AppliedOfficial difficulty: 13%PolynomialsTier B - browser, with the efficient algorithmNot viewed
↖ Euler Lab

A natural number, \(N\), that can be written as the sum and product of a given set of at least two natural numbers, \(\{a_1, a_2, \dots, a_k\}\) is called a product-sum number: \(N = a_1 + a_2 + \cdots + a_k = a_1 \times a_2 \times \cdots \times a_k\).

For example, \(6 = 1 + 2 + 3 = 1 \times 2 \times 3\).

For a given set of size, \(k\), we shall call the smallest \(N\) with this property a minimal product-sum number. The minimal product-sum numbers for sets of size, \(k = 2, 3, 4, 5\), and \(6\) are as follows.

  • \(k=2\): \(4 = 2 \times 2 = 2 + 2\)
  • \(k=3\): \(6 = 1 \times 2 \times 3 = 1 + 2 + 3\)
  • \(k=4\): \(8 = 1 \times 1 \times 2 \times 4 = 1 + 1 + 2 + 4\)
  • \(k=5\): \(8 = 1 \times 1 \times 2 \times 2 \times 2 = 1 + 1 + 2 + 2 + 2\)
  • \(k=6\): \(12 = 1 \times 1 \times 1 \times 1 \times 2 \times 6 = 1 + 1 + 1 + 1 + 2 + 6\)

Hence for \(2 \le k \le 6\), the sum of all the minimal product-sum numbers is \(4+6+8+12 = 30\); note that \(8\) is only counted once in the sum.

In fact, as the complete set of minimal product-sum numbers for \(2 \le k \le 12\) is \(\{4, 6, 8, 12, 15, 16\}\), the sum is \(61\).

What is the sum of all the minimal product-sum numbers for \(2 \le k \le 12000\)?

This problem is taken from Project Euler, Problem 88.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=88. Published Friday, 4th February 2005, 06:00 pm. Solved by 12,102 members at time of mirroring.

Why this is useful

General Problem Solving. Builds computational thinking, decomposition, and debugging discipline - transferable, without a specific financial application.

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

Prerequisites

Lessons that prepare you:
1.1 Sets, Functions, and Relations · 17.1 Python for Quants: NumPy, pandas, and Vectorization · 2.1 Functions, Limits, and Continuity · 4.2 Linear Maps, Matrices, Rank, and the Null Space

Recommended stepping-stone problems: #52 · #33 · #27

Concepts: algebra

Likely techniques: hashing

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.