Project Euler Lab - Problem 739

#739 - Summation of Summations

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

Take a sequence of length \(n\). Discard the first term then make a sequence of the partial summations. Continue to do this over and over until we are left with a single term. We define this to be \(f(n)\).

Consider the example where we start with a sequence of length 8:

\( \begin{array}{rrrrrrrr} 1&1&1&1&1&1&1&1\\ &1&2&3&4&5& 6 &7\\ & &2&5&9&14&20&27\\ & & &5&14&28&48&75\\ & & & &14&42&90&165\\ & & & & & 42 & 132 & 297\\ & & & & & & 132 &429\\ & & & & & & &429\\ \end{array} \)

Then the final number is \(429\), so \(f(8) = 429\).

For this problem we start with the sequence \(1,3,4,7,11,18,29,47,\ldots\)
This is the Lucas sequence where two terms are added to get the next term.
Applying the same process as above we get \(f(8) = 2663\).
You are also given \(f(20) = 742296999 \) modulo \(1\,000\,000\,007\)

Find \(f(10^8)\). Give your answer modulo \(1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 739.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=739. Published Sunday, 20th December 2020, 10:00 am. Solved by 653 members at time of mirroring.

Why this is useful

Mathematical Foundation. Exact integer reasoning and algorithmic efficiency. Foundational rigour and computational discipline rather than a direct trading application.

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.