PROJECT EULER · #0872
Recursive Tree
A sequence of rooted trees
The sequence starts at
For
- Trace a path from the root of
to a leaf by following the largest-numbered child at each node. - Remove all edges along the traced path, disconnecting all nodes along it from their parents.
- Connect all orphaned nodes directly to a new node numbered
, which becomes the root of .
For example, the following figure shows

Let
Find
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.