# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/
Search: id:a193573
Showing 1-1 of 1
%I A193573 #24 Aug 03 2023 14:11:39
%S A193573 31,68,7,19,23,1,219,293,70,193,208,32,748,1233,1457,973,263,338,49,
%T A193573 109,763,5606,239,1487,8884,1933,1636,139,1607,3932,409,18280,17966,
%U A193573 4366,4960,16181,33464,3564,18899,496,4995,566,144164,3392,5066,388292,194962,178085
%N A193573 Least happy number with next happy number of distance n.
%C A193573 The next term, a(43), equals 144164. [From Harvey P. Dale, Aug 27 2011]
%C A193573 a(88) = 469999871, a(92) = 488849933, a(96) = 1289999763, a(95) = 1688999664, a(104) = 3999991962, a(116) = 5888999662. - _Chai Wah Wu_, Aug 03 2023
%H A193573 Chai Wah Wu, Table of n, a(n) for n = 1..86
%H A193573 Eric Weisstein's World of Mathematics, Happy Number.
%e A193573 a(1) = 31 since next happy number is 32 with distance 1.
%e A193573 a(2) = 68 since next happy number is 70 with distance 2.
%e A193573 a(3) = 7 since next happy number is 10 with distance 3.
%t A193573 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 *)
%o A193573 (Python)
%o A193573 from itertools import count
%o A193573 def A193573(n):
%o A193573 a = 1
%o A193573 for k in count(2):
%o A193573 m = k
%o A193573 while m not in {1,37,58,89,145,42,20,4,16}:
%o A193573 m = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(m))
%o A193573 if m == 1:
%o A193573 if k-a==n:
%o A193573 return a
%o A193573 a = k # _Chai Wah Wu_, Aug 03 2023
%Y A193573 Cf. A007770.
%K A193573 nonn,base
%O A193573 1,1
%A A193573 _Martin Renner_, Jul 31 2011
%E A193573 a(43) from _Harvey P. Dale_, Aug 27 2011
%E A193573 a(44)-a(48) from _Chai Wah Wu_, Aug 03 2023
# Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE