Project Euler Lab - Problem 955

#955 - Finding Triangles

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

A sequence \((a_n)_{n \ge 0}\) starts with \(a_0 = 3\) and for each \(n \ge 0\),

  • if \(a_n\) is a triangle numberA triangle number is a number of the form \(m(m + 1)/2\) for some integer \(m\)., then \(a_{n + 1} = a_n + 1\);
  • otherwise, \(a_{n + 1} = 2a_n - a_{n - 1} + 1\).

The sequence begins: \[{\color{red}3}, 4, {\color{red}6}, 7, 9, 12, 16, {\color{red}21}, 22, 24, 27, 31, {\color{red}36}, 37, 39, 42, \dots\] where triangle numbers are marked red.

The \(10\)th triangle number in the sequence is \(a_{2964} = 1439056\).
Find the index \(n\) such that \(a_n\) is the \(70\)th triangle number in the sequence.

This problem is taken from Project Euler, Problem 955.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=955. Published Sunday, 20th July 2025, 11:00 am. Solved by 650 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 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.