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 A350651 #8 Jan 24 2022 16:11:38 %S A350651 1,2,1,3,2,3,1,2,1,4,3,3,2,2,2,3,1,2,1,2,1,3,2,3,1,2,1,4,3,3,2,7,1,7, %T A350651 6,6,5,4,4,4,3,5,3,4,3,4,1,2,1,3,2,3,1,2,1,2,1,3,2,3,1,2,1,4,3,3,2,2, %U A350651 2,3,1,2,1,2,1,3,2,3,1,2,1,4,3,3,2,6,1 %N A350651 a(n) is the size of the orbit of n under repeated application of A350229 (the sum of a number and its balanced ternary digits). %C A350651 This sequence is well defined: %C A350651 - for any w such that 3^w > 2*w + 2: %C A350651 - let M(w) (resp. m(w)) be the number whose balanced ternary expansion %C A350651 starts with "1T" %C A350651 followed by w T's %C A350651 followed by w 1's (resp. w T's), %C A350651 - for any u in the interval m(w)..M(w), A350229(u) <= u <= M(w), %C A350651 - also for any v < m(k), A350229(v) < m(k) + 2*w + 2 <= M(w), %C A350651 - and the orbit of any number <= M(w) will be trapped in the interval 0..M(w), %C A350651 - hence for any number n, we can find an appropriate w, so the orbit of n is bounded and eventually periodic (with a finite size), QED. %C A350651 This sequence is unbounded. %F A350651 a(n) = #{ A350229^k(n), k >= 0 } (where f^k corresponds to the k-th iterate of f). %e A350651 For n = 9: %e A350651 - the orbit of 9 contains the following values: %e A350651 k v bter(v) ds(v) %e A350651 - -- ------- ----- %e A350651 0 9 100 1 %e A350651 1 10 101 2 %e A350651 2 12 110 2 %e A350651 3 14 1TTT -2 %e A350651 4 12 110 2 %e A350651 - so a(9) = #{ 9, 10, 12, 14 } = 4. %t A350651 f[n_] := n + Total[If[First@ # == 0, Rest@ #, #] &[Prepend[IntegerDigits[n, 3], 0] //. {x___, y_, k_ /; k > 1, z___} :> {x, y + 1, k - 3, z}]]; Array[-1 + Length@ NestWhileList[f, #, UnsameQ, All] &, 105, 0] (* _Michael De Vlieger_, Jan 15 2022 *) %o A350651 (PARI) b(n) = my (v=n, d); while (n, n=(n-d=[0,1,-1][1+n%3])/3; v+=d); v %o A350651 a(n) = my (s=[]); while (!setsearch(s, n), s=setunion(s, [n]); n=b(n)); #s %Y A350651 Cf. A065363, A350229. %K A350651 nonn,base %O A350651 0,2 %A A350651 _Rémy Sigrist_, Jan 09 2022