|
|
A090425
|
|
Number of iterations required for happy number A007770(n) to converge to 1.
|
|
3
|
|
|
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, 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, 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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
The count includes both the start and end.
|
|
LINKS
|
|
|
EXAMPLE
|
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.
|
|
MATHEMATICA
|
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 *)
|
|
PROG
|
(Haskell)
a090425 n = snd $ until ((== 1) . fst)
(\(u, v) -> (a003132 u, v + 1)) (a007770 n, 1)
(Python)
from itertools import count, islice
def A090425_gen(): # generator of terms
for n in count(1):
c = 1
while n not in {1, 37, 58, 89, 145, 42, 20, 4, 16}:
n = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(n))
c += 1
if n == 1:
yield c
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|