login
A392990
Unhappy numbers that are sandwiched between two consecutive happy numbers.
1
69, 189, 191, 292, 330, 366, 564, 636, 654, 672, 762, 819, 900, 911, 922, 999, 1089, 1091, 1113, 1183, 1210, 1276, 1289, 1331, 1334, 1336, 1338, 1473, 1573, 1726, 1743, 1753, 1759, 1770, 1813, 1901, 2092, 2110, 2176, 2189, 2259, 2332, 2456, 2486, 2546, 2556
OFFSET
1,1
COMMENTS
In other words, numbers k such that k - 1 and k + 1 are happy but k is not.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000 (terms 1..1310 from Xander Lee Luo)
MATHEMATICA
happyQ[n_] := NestWhile[Total[IntegerDigits[#]^2] &, n, UnsameQ, All] == 1; seq[lim_] := Module[{h = Select[Range[lim], happyQ], ind}, ind = Position[Differences[h], 2] // Flatten; h[[ind]] + 1]; seq[2600] (* Amiram Eldar, Jan 30 2026 *)
PROG
(Python)
from itertools import count, islice
def ssd(n): return sum(int(d)**2 for d in str(n))
def is_happy(n):
while n not in [1, 4]: n = ssd(n) # iterate until fixed point or in cycle
return n==1
def agen(): # generator of terms
h1, h2, h3 = True, False, False
for k in count(2):
if (h1, h2, h3) == (True, False, True): yield k
h1, h2, h3 = h2, h3, is_happy(k+2)
print(list(islice(agen(), 46))) # Michael S. Branicky, Feb 04 2026
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Xander Lee Luo, Jan 29 2026
STATUS
approved