OFFSET
1,2
COMMENTS
LINKS
Nathan Fox, Table of n, a(n) for n = 1..12205
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,new
AUTHOR
N. Bradley Fox, Nathan Fox, Helen Grundman, Rachel Lynn, Changningphaabi Namoijam, Mary Vanderschoot, Oct 15 2024
STATUS
approved