OFFSET
0,2
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.
FORMULA
a(n) = #{ A350229^k(n), k >= 0 } (where f^k corresponds to the k-th iterate of f).
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 09 2022
STATUS
approved