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.
%I A193565 #20 Feb 16 2025 08:33:15 %S A193565 2,4,11,78,87,101,110,113,131,168,179,186,197,200,249,257,259,275,294, %T A193565 295,311,429,449,467,476,492,494,527,529,559,567,572,576,592,595,618, %U A193565 647,657,674,675,681,708,719,725,746,752,756,764,765,779,780,791,797 %N A193565 Unhappy numbers which enter the cycle (4, 16, 37, 58, 89, 145, 42, 20) at 4. %H A193565 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/UnhappyNumber.html">Unhappy Number</a>. %e A193565 7899 is such a number of height 6 because it enters the cycle at 4 in 6 steps: 7899 -> 275 -> 78 -> 113 -> 11 -> 2 -> 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 -> ... %p A193565 S:=proc(n) local Q,k,N,z; Q:=[n]; for k from 1 do N:=convert(Q[k],base,10); z:=sum(N['i']^2,'i'=1..nops(N)); if not member(z,Q) then Q:=[op(Q),z]; else Q:=[op(Q),z]; break; fi; od; return Q; end: %p A193565 a:=[]: for i from 1 while nops(a)<30 do Q:=S(i); A:=Q[nops(Q)]; if A=4 then a:=[op(a),i] fi; od: print(op(a)); %Y A193565 Cf. A031177, A039943. %K A193565 nonn,base %O A193565 1,1 %A A193565 _Martin Renner_, Jul 31 2011