login
A377089
Numbers that are both happy (A007770) and elated (A376272).
1
1, 10, 13, 97, 100, 103, 130, 226, 262, 319, 356, 365, 391, 556, 565, 907, 970, 1000, 1003, 1030, 1122, 1177, 1188, 1212, 1221, 1222, 1277, 1300, 1339, 1393, 1448, 1478, 1484, 1487, 1557, 1575, 1717, 1727, 1748, 1755, 1771, 1772, 1784, 1818, 1844, 1847, 1874
OFFSET
1,2
COMMENTS
Every power of 10 is in this sequence, as both the sum of squared digits map (A003132) and the map A376270 map powers of 10 to 1.
PROG
(Python)
def ssd(n): return sum(int(d)**2 for d in str(n))
def f(n): return (d:=list(map(int, str(n))))[0] * sum(di*di for di in d)
def happy(n):
if n == 1: return True
s = list(map(int, str(n)))
while n not in [1, 4]: n = ssd(n) # iterate until fixed point or cycle
return n == 1
def elated(n):
if n == 1: return True
traj = {n}
while (n:=f(n)) not in traj: traj.add(n)
return 1 in traj
def ok(n): return happy(n) and elated(n)
print([k for k in range(1, 2001) if ok(k)]) # Michael S. Branicky, Oct 16 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. Bradley Fox, Nathan Fox, Helen Grundman, Rachel Lynn, Changningphaabi Namoijam, Mary Vanderschoot, Oct 15 2024
STATUS
approved