A Unified Closed-Form Formula for the Multi-Peg Tower of Hanoi via Simplex Number Theory

Abhiram Menon

Published: 2025/5/19

Abstract

The classical three-peg Tower of Hanoi puzzle admits the well-known closed-form solution \(M(3,n)=2^n-1\), but the general case with \(p \geq 4\) pegs has remained an open problem for over a century. In this paper, we present a complete unified closed-form formula for the minimum number of moves \(M(p,n)\) required to solve the Tower of Hanoi problem for any number of pegs \(p\) and disks \(n\). Building upon our previous work, which introduced Menon's Conjecture \(M(p,n)=4n-2p+1\) for the restricted domain \(p-1 \leq n \leq \frac{p(p-1)}{2}\), we now extend this result to all values of \(n\). Our key insight is that the solution naturally partitions into regimes governed by simplex number boundaries, with each regime exhibiting linear growth with slopes that are successive powers of two. This leads to the unified expression: \[ M(p,n) = 2^{i+1}n - \sum_{k=0}^{i} 2^k \binom{p+k-2}{k}, \quad i = \min \left\{ j \geq 0 : n \leq \binom{p-1+j}{j+1} \right\}. \] We show how this formula recovers classical results, including \(M(3,n)=2^n-1\) and the four-peg Reve's Puzzle solution, as special cases. Computational verification across more than 1,750 test instances confirms perfect agreement with Frame-Stewart values. Furthermore, this closed-form reduces the complexity of determining \(M(p,n)\) from \(O(pn^2)\) to \(O(p\log n)\), providing both theoretical unification and practical computational improvements.

A Unified Closed-Form Formula for the Multi-Peg Tower of Hanoi via Simplex Number Theory | SummarXiv | SummarXiv