cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A090425 Number of iterations required for happy number A007770(n) to converge to 1.

This page as a plain text file.
%I A090425 #29 Feb 16 2025 08:32:51
%S A090425 1,6,2,3,5,4,4,3,4,5,5,3,6,4,4,3,5,5,4,2,3,5,4,3,6,6,4,4,5,5,4,6,4,4,
%T A090425 4,6,4,6,6,6,6,4,4,6,3,4,3,6,6,4,6,6,6,5,7,6,7,6,6,6,7,5,6,6,6,7,5,5,
%U A090425 5,4,4,7,5,5,5,7,7,4,7,4,5,3,4,6,6,6,7,6,6,4,7,7,4,5,5,4,6,3,6,7,6,4
%N A090425 Number of iterations required for happy number A007770(n) to converge to 1.
%C A090425 The count includes both the start and end.
%H A090425 Reinhard Zumkeller, <a href="/A090425/b090425.txt">Table of n, a(n) for n = 1..10000</a>
%H A090425 T. Cai and Xia Zhou, <a href="http://dx.doi.org/10.1216/RMJ-2008-38-6-1921">On the heights of happy numbers</a>, Rocky Mount. J. Math. 38 (6) (2008) 1921-1926. [From _R. J. Mathar_, Apr 22 2010]
%H A090425 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/HappyNumber.html">Happy Number</a>.
%e A090425 7 is the 2nd happy number and iterated digit squarings and additions give the sequence {7,49,97,130,10,1}, so a(2)=6.
%t A090425 happy[n_] := If[(list = NestWhileList[Plus @@ (IntegerDigits[#]^2) &, n, UnsameQ, All])[[-1]] == 1, Length[list] - 1, Nothing]; Array[happy, 700] (* _Amiram Eldar_, Apr 12 2022 *)
%o A090425 (Haskell)
%o A090425 a090425 n = snd $ until ((== 1) . fst)
%o A090425                         (\(u, v) -> (a003132 u, v + 1)) (a007770 n, 1)
%o A090425 -- _Reinhard Zumkeller_, Aug 07 2012
%o A090425 (Python)
%o A090425 from itertools import count, islice
%o A090425 def A090425_gen(): # generator of terms
%o A090425     for n in count(1):
%o A090425         c = 1
%o A090425         while n not in {1,37,58,89,145,42,20,4,16}:
%o A090425             n = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(n))
%o A090425             c += 1
%o A090425         if n == 1:
%o A090425             yield c
%o A090425 A090425_list = list(islice(A090425_gen(),20)) # _Chai Wah Wu_, Aug 02 2023
%Y A090425 Cf. A007770.
%Y A090425 Cf. A003132.
%K A090425 nonn,base
%O A090425 1,2
%A A090425 _Eric W. Weisstein_, Nov 30 2003