login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Least happy number with next happy number of distance n.
1

%I #24 Aug 03 2023 14:11:39

%S 31,68,7,19,23,1,219,293,70,193,208,32,748,1233,1457,973,263,338,49,

%T 109,763,5606,239,1487,8884,1933,1636,139,1607,3932,409,18280,17966,

%U 4366,4960,16181,33464,3564,18899,496,4995,566,144164,3392,5066,388292,194962,178085

%N Least happy number with next happy number of distance n.

%C The next term, a(43), equals 144164. [From Harvey P. Dale, Aug 27 2011]

%C 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 Chai Wah Wu, <a href="/A193573/b193573.txt">Table of n, a(n) for n = 1..86</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/HappyNumber.html">Happy Number</a>.

%e a(1) = 31 since next happy number is 32 with distance 1.

%e a(2) = 68 since next happy number is 70 with distance 2.

%e a(3) = 7 since next happy number is 10 with distance 3.

%t 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 (Python)

%o from itertools import count

%o def A193573(n):

%o a = 1

%o for k in count(2):

%o m = k

%o while m not in {1,37,58,89,145,42,20,4,16}:

%o m = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(m))

%o if m == 1:

%o if k-a==n:

%o return a

%o a = k # _Chai Wah Wu_, Aug 03 2023

%Y Cf. A007770.

%K nonn,base

%O 1,1

%A _Martin Renner_, Jul 31 2011

%E a(43) from _Harvey P. Dale_, Aug 27 2011

%E a(44)-a(48) from _Chai Wah Wu_, Aug 03 2023