cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A377089 Numbers that are both happy (A007770) and elated (A376272).

This page as a plain text file.
%I A377089 #12 Oct 16 2024 20:56:29
%S A377089 1,10,13,97,100,103,130,226,262,319,356,365,391,556,565,907,970,1000,
%T A377089 1003,1030,1122,1177,1188,1212,1221,1222,1277,1300,1339,1393,1448,
%U A377089 1478,1484,1487,1557,1575,1717,1727,1748,1755,1771,1772,1784,1818,1844,1847,1874
%N A377089 Numbers that are both happy (A007770) and elated (A376272).
%C A377089 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.
%H A377089 Nathan Fox, <a href="/A377089/b377089.txt">Table of n, a(n) for n = 1..12205</a>
%o A377089 (Python)
%o A377089 def ssd(n): return sum(int(d)**2 for d in str(n))
%o A377089 def f(n): return (d:=list(map(int, str(n))))[0] * sum(di*di for di in d)
%o A377089 def happy(n):
%o A377089     if n == 1: return True
%o A377089     s = list(map(int, str(n)))
%o A377089     while n not in [1, 4]: n = ssd(n) # iterate until fixed point or cycle
%o A377089     return n == 1
%o A377089 def elated(n):
%o A377089     if n == 1: return True
%o A377089     traj = {n}
%o A377089     while (n:=f(n)) not in traj: traj.add(n)
%o A377089     return 1 in traj
%o A377089 def ok(n): return happy(n) and elated(n)
%o A377089 print([k for k in range(1, 2001) if ok(k)]) # _Michael S. Branicky_, Oct 16 2024
%Y A377089 Cf. A003132, A007770, A376270, A376272.
%K A377089 nonn,base
%O A377089 1,2
%A A377089 N. Bradley Fox, _Nathan Fox_, Helen Grundman, Rachel Lynn, Changningphaabi Namoijam, Mary Vanderschoot, Oct 15 2024