OFFSET
0,3
COMMENTS
Although this is a list, we use an offset equal to 0; thus:
- the binary expansion of n has the same number of digits as the balanced ternary expansion of a(n) (ignoring leading zeros),
- for n > 0 with binary expansion (b_1, ..., b_w) (where b_1 = 1), let's say that the balanced ternary expansion of a(n) is (t_1, ..., t_w) (where t_1 = 1):
- for i = 2..w:
- if b_i = 0, then t_i = min({-1, 0, +1} \ {t_{i-1}}),
- otherwise, t_i = max({-1, 0, +1} \ {t_{i-1}}).
For any w > 0, there are 2^(w-1) positive terms with w balanced ternary digits.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8191
EXAMPLE
The first terms, alongside their balanced ternary expansions, are:
n a(n) bter(a(n))
-- ---- ----------
1 0 0
2 1 1
3 2 1T
4 3 10
5 6 1T0
6 7 1T1
7 8 10T
8 10 101
9 17 1T0T
10 19 1T01
11 20 1T1T
12 21 1T10
13 24 10T0
14 25 10T1
15 29 101T
16 30 1010
PROG
(PARI) is(n) = { while (n, my (d = centerlift(Mod(n, 3))); n = (n-d)/3; if (d==centerlift(Mod(n, 3)), return (0); ); ); return (1); }
(PARI) a(n) = { my (d = binary(n)); for (i = 2, #d, d[i] = setminus([-1, 0, 1], [d[i-1]])[1+d[i]]; ); fromdigits(d, 3); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 17 2024
STATUS
approved