Happy numbers runs, heights, and a census

Square the digits and add: 19 → 1² + 9² = 82 → 68 → 100 → 1. A number is happy if it ends at 1; every other number falls into the loop 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4. About one number in seven is happy, but runs of them are rare: the first run of six starts at a 25-digit number, and the first run of thirteen at a number with 603,699 digits. This page finds them by an exhaustive search that proves each one is the smallest, and works the same way in any base.

Puzzle: pick a base and a number of digits, then find where the longest run of consecutive happy numbers starts. The target is the true maximum from a census of every number; the solver shows the first run.

run hunt

trajectory — any number, also huge ones like 58{9:11}6{9:144}5 (run notation)

how many are happy? — share of happy numbers in 1..10ⁿ, n = 2.. (digit DP)

 

first run of n consecutive happy numbers — A055629, proved smallest

smallest happy number of height n — A001273: (K−1) then E nines

checks