OFFSET
1,1
COMMENTS
The next term, a(43), equals 144164. [From Harvey P. Dale, Aug 27 2011]
a(88) = 469999871, a(92) = 488849933, a(96) = 1289999763, a(95) = 1688999664, a(104) = 3999991962, a(116) = 5888999662. - Chai Wah Wu, Aug 03 2023
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..86
Eric Weisstein's World of Mathematics, Happy Number.
EXAMPLE
a(1) = 31 since next happy number is 32 with distance 1.
a(2) = 68 since next happy number is 70 with distance 2.
a(3) = 7 since next happy number is 10 with distance 3.
MATHEMATICA
hapQ[n_]:=Last[NestWhileList[Total[IntegerDigits[#]^2]&, n, !MemberQ[{0, 1, 4, 16, 20, 37, 42, 58, 89, 145}, #]&]]==1; Transpose[With[ {hapnos= Partition[ Select[Range[34000], hapQ], 2, 1]}, Table[First[Select[ hapnos, Last[#]-First[#]==n&]], {n, 42}]]][[1]] (* Harvey P. Dale, Aug 27 2011 *)
PROG
(Python)
from itertools import count
def A193573(n):
a = 1
for k in count(2):
m = k
while m not in {1, 37, 58, 89, 145, 42, 20, 4, 16}:
m = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(m))
if m == 1:
if k-a==n:
return a
a = k # Chai Wah Wu, Aug 03 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Martin Renner, Jul 31 2011
EXTENSIONS
a(43) from Harvey P. Dale, Aug 27 2011
a(44)-a(48) from Chai Wah Wu, Aug 03 2023
STATUS
approved