login
A031177
Unhappy numbers: numbers having period-8 2-digitized sequences.
22
2, 3, 4, 5, 6, 8, 9, 11, 12, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25, 26, 27, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 83
OFFSET
1,1
LINKS
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
A031177_list = list(islice(A031177_gen(), 20)) # Chai Wah Wu, Aug 02 2023
CROSSREFS
Complement of happy numbers A007770. Cf. A056527.
Sequence in context: A066022 A052047 A078831 * A164119 A308017 A184107
KEYWORD
nonn,base
STATUS
approved