Let be the expected remaining time when the walk is at . The first-step recurrence for gambler's ruin iswith . The quadraticsatisfies both the recurrence and the boundary conditions, and their finite linear system has a unique solution. Starting from zero therefore gives
Solved by gpt-5.6-sol high.
Codex Wiki