Project Euler Lab - Problem 985

#985 - Telescoping Triangles

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

Given a triangle \(T_k\), it is sometimes possible to construct a triangle \(T_{k+1}\) inside \(T_k\) such that

  • The three vertices of \(T_{k+1}\) lie one on each side of \(T_k\).
  • For each side of \(T_k\), the angles formed between it and the two sides of \(T_{k+1}\) it touches are equal to each other.
0985_telescoping_triangles.png

Illustrated above is such a sequence of three triangles starting with \(T_0\) (in blue) having side lengths \((8,9,10)\). Then \(T_1\) is shown in green and \(T_2\) in red. However, no triangle can be drawn inside \(T_2\) that satisfies the requirements. In other words, \(T_3\) does not exist.

Amongst all integer-sided triangles \(T_0\) such that \(T_2\) exists but \(T_3\) does not exist, the smallest possible perimeter is \(10\) when \(T_0\) has side lengths \((3, 3, 4)\).

Suppose another triangle \(T_0\) has integer side lengths, and \(T_{20}\) exists, but \(T_{21}\) does not exist. What is the smallest possible perimeter of \(T_0\)?

This problem is taken from Project Euler, Problem 985.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=985. Published Saturday, 21st February 2026, 10:00 pm. Solved by 358 members at time of mirroring.

Why this is useful

Algorithmic Development. Graph/state-space search transfers to routing, dependency resolution, and execution-path optimisation (Phases 16, 17).

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.