Project Euler Lab - Problem 651

#651 - Patterned Cylinders

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

An infinitely long cylinder has its curved surface fully covered with different coloured but otherwise identical rectangular stickers, without overlapping. The stickers are aligned with the cylinder, so two of their edges are parallel with the cylinder's axis, with four stickers meeting at each corner.

Let \(a>0\) and suppose that the colouring is periodic along the cylinder, with the pattern repeating every \(a\) stickers. (The period is allowed to be any divisor of \(a\).) Let \(b\) be the number of stickers that fit round the circumference of the cylinder.

Let \(f(m, a, b)\) be the number of different such periodic patterns that use exactly \(m\) distinct colours of stickers. Translations along the axis, reflections in any plane, rotations in any axis, (or combinations of such operations) applied to a pattern are to be counted as the same as the original pattern.

You are given that \(f(2, 2, 3) = 11\), \(f(3, 2, 3) = 56\), and \(f(2, 3, 4) = 156\). Furthermore, \(f(8, 13, 21) \equiv 49718354 \pmod{1\,000\,000\,007}\), and \(f(13, 144, 233) \equiv 907081451 \pmod{1\,000\,000\,007}\).

Find \(\sum_{i=4}^{40} f(i, F_{i-1}, F_i) \bmod 1\,000\,000\,007\), where \(F_i\) are the Fibonacci numbers starting at \(F_0=0\), \(F_1=1\).

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