Project Euler Lab - Problem 545

#545 - Faulhaber's Formulas

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

The sum of the \(k\)th powers of the first \(n\) positive integers can be expressed as a polynomial of degree \(k+1\) with rational coefficients, the Faulhaber's Formulas:
\(1^k + 2^k + ... + n^k = \sum_{i=1}^n i^k = \sum_{i=1}^{k+1} a_{i} n^i = a_{1} n + a_{2} n^2 + ... + a_{k} n^k + a_{k+1} n^{k + 1}\),
where \(a_i\)'s are rational coefficients that can be written as reduced fractions \(p_i/q_i\) (if \(a_i = 0\), we shall consider \(q_i = 1\)).

For example, \(1^4 + 2^4 + ... + n^4 = -\frac 1 {30} n + \frac 1 3 n^3 + \frac 1 2 n^4 + \frac 1 5 n^5.\)

Define \(D(k)\) as the value of \(q_1\) for the sum of \(k\)th powers (i.e. the denominator of the reduced fraction \(a_1\)).
Define \(F(m)\) as the \(m\)th value of \(k \ge 1\) for which \(D(k) = 20010\).
You are given \(D(4) = 30\) (since \(a_1 = -1/30\)), \(D(308) = 20010\), \(F(1) = 308\), \(F(10) = 96404\).

Find \(F(10^5)\).

This problem is taken from Project Euler, Problem 545.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=545. Published Saturday, 30th January 2016, 10:00 pm. Solved by 661 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.

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.