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.

A371276 Nonnegative numbers whose balanced ternary expansions have no consecutive equal digits (with offset 0).

Original entry on oeis.org

0, 1, 2, 3, 6, 7, 8, 10, 17, 19, 20, 21, 24, 25, 29, 30, 51, 52, 56, 57, 60, 61, 62, 64, 71, 73, 74, 75, 87, 88, 89, 91, 152, 154, 155, 156, 168, 169, 170, 172, 179, 181, 182, 183, 186, 187, 191, 192, 213, 214, 218, 219, 222, 223, 224, 226, 260, 262, 263, 264
Offset: 0

Views

Author

Rémy Sigrist, Mar 17 2024

Keywords

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.

Examples

			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
		

Crossrefs

See A031941 for a similar sequence.
Cf. A134021.

Programs

  • 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); }