login
First differences of A007770 (happy numbers).
0

%I #15 Aug 30 2022 14:29:05

%S 6,3,3,6,4,5,3,1,12,5,19,2,9,3,4,5,3,3,3,3,6,20,1,3,6,28,9,12,2,2,1,

%T 10,5,11,7,4,6,3,23,1,17,11,2,8,1,8,3,6,1,6,3,2,7,18,6,3,2,1,8,3,4,3,

%U 5,1,5,7,5,31,6,18,5,9,9,3,6,40,20,7,2,1,42,9,5,1,9,3,2,1

%N First differences of A007770 (happy numbers).

%C El-Sedy and Siksek show that there exist arbitrarily long runs of consecutive integers that are happy numbers. So this sequence contains arbitrarily long runs of 1's.

%H E. El-Sedy and S. Siksek, <a href="https://doi.org/10.1216/rmjm/1022009281">On happy numbers</a>, Rocky Mountain J. Math. 30 (2000), 565-570.

%F a(n) = A007770(n+1) - A007770(n), where A007770(n) is the n-th happy number.

%t happyQ[n_] := NestWhile[Plus @@ (IntegerDigits[#]^2) &, n, UnsameQ, All] == 1; Differences @ Select[Range[700], happyQ] (* _Amiram Eldar_, Aug 06 2022 *)

%o (Python)

%o from itertools import count, islice

%o def ssd(n): return sum(int(d)**2 for d in str(n))

%o def ok(n):

%o while n not in [1, 4]: n = ssd(n) # iterate until fixed point/cycle

%o return n==1

%o def agen(): # generator of terms

%o prevk = 1

%o for k in count(2):

%o if ok(k): yield k - prevk; prevk = k

%o print(list(islice(agen(), 88))) # _Michael S. Branicky_, Aug 06 2022

%Y Cf. A007770.

%K nonn,base

%O 1,1

%A _DarĂ­o D. Devia_, Aug 05 2022