OFFSET
1,1
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Digitaddition
Eric Weisstein's World of Mathematics, Unhappy Number
PROG
(Haskell)
a031177 n = a031177_list !! (n-1)
a031177_list = filter ((/= 1) . a103369) [1..]
-- Reinhard Zumkeller, Aug 24 2011
(Python)
from itertools import count, islice
def A031177_gen(startvalue=1): # generator of terms >= startvalue
for n in count(max(startvalue, 1)):
m = n
while m not in {1, 37, 58, 89, 145, 42, 20, 4, 16}:
m = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(m))
if m > 1:
yield n
CROSSREFS
KEYWORD
nonn,base
AUTHOR
STATUS
approved