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.

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).

Original entry on oeis.org

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, 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, 2, 3, 1, 2, 1, 2, 1, 3, 2, 3, 1, 2, 1, 4, 3, 3, 2, 6, 1
Offset: 0

Views

Author

Rémy Sigrist, Jan 09 2022

Keywords

Comments

This sequence is well defined:
- for any w such that 3^w > 2*w + 2:
- let M(w) (resp. m(w)) be the number whose balanced ternary expansion
starts with "1T"
followed by w T's
followed by w 1's (resp. w T's),
- for any u in the interval m(w)..M(w), A350229(u) <= u <= M(w),
- also for any v < m(k), A350229(v) < m(k) + 2*w + 2 <= M(w),
- and the orbit of any number <= M(w) will be trapped in the interval 0..M(w),
- 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.
This sequence is unbounded.

Examples

			For n = 9:
- the orbit of 9 contains the following values:
  k  v   bter(v)  ds(v)
  -  --  -------  -----
  0   9      100      1
  1  10      101      2
  2  12      110      2
  3  14     1TTT     -2
  4  12      110      2
- so a(9) = #{ 9, 10, 12, 14 } = 4.
		

Crossrefs

Programs

  • Mathematica
    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 *)
  • PARI
    b(n) = my (v=n, d); while (n, n=(n-d=[0,1,-1][1+n%3])/3; v+=d); v
    a(n) = my (s=[]); while (!setsearch(s, n), s=setunion(s, [n]); n=b(n)); #s

Formula

a(n) = #{ A350229^k(n), k >= 0 } (where f^k corresponds to the k-th iterate of f).