Project Euler Lab - Problem 61

#61 - Cyclical Figurate Numbers

● FoundationOfficial difficulty: 7%PointsTier A - full browser executionNot viewed
↖ Euler Lab

Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:

Triangle   \(P_{3,n}=n(n+1)/2\)   \(1, 3, 6, 10, 15, \dots\)
Square   \(P_{4,n}=n^2\)   \(1, 4, 9, 16, 25, \dots\)
Pentagonal   \(P_{5,n}=n(3n-1)/2\)   \(1, 5, 12, 22, 35, \dots\)
Hexagonal   \(P_{6,n}=n(2n-1)\)   \(1, 6, 15, 28, 45, \dots\)
Heptagonal   \(P_{7,n}=n(5n-3)/2\)   \(1, 7, 18, 34, 55, \dots\)
Octagonal   \(P_{8,n}=n(3n-2)\)   \(1, 8, 21, 40, 65, \dots\)

The ordered set of three \(4\)-digit numbers: \(8128\), \(2882\), \(8281\), has three interesting properties.

  1. The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first).
  2. Each polygonal type: triangle (\(P_{3,127}=8128\)), square (\(P_{4,91}=8281\)), and pentagonal (\(P_{5,44}=2882\)), is represented by a different number in the set.
  3. This is the only set of \(4\)-digit numbers with this property.

Find the sum of the only ordered set of six cyclic \(4\)-digit numbers for which each polygonal type: triangle, square, pentagonal, hexagonal, heptagonal, and octagonal, is represented by a different number in the set.

This problem is taken from Project Euler, Problem 61.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=61. Published Friday, 16th January 2004, 06:00 pm. Solved by 29,333 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 A - full browser execution
Runs at full original scale within the browser limits.

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.