Project Euler Lab - Problem 684

#684 - Inverse Digit Sum

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

Define \(s(n)\) to be the smallest number that has a digit sum of \(n\). For example \(s(10) = 19\).
Let \(\displaystyle S(k) = \sum_{n=1}^k s(n)\). You are given \(S(20) = 1074\).

Further let \(f_i\) be the Fibonacci sequence defined by \(f_0=0, f_1=1\) and \(f_i=f_{i-2}+f_{i-1}\) for all \(i \ge 2\).

Find \(\displaystyle \sum_{i=2}^{90} S(f_i)\). Give your answer modulo \(1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 684.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=684. Published Saturday, 19th October 2019, 04:00 pm. Solved by 3,196 members at time of mirroring.

Why this is useful

Numerical Computing. Matrix methods and linear-recurrence acceleration are the machinery behind covariance work, PCA, and lattice/transition models (Phases 4, 5, 8).

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.