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.

A371275 a(n) is the number of runs in the balanced ternary expansion of n.

Original entry on oeis.org

0, 1, 2, 2, 1, 2, 3, 3, 3, 2, 3, 2, 2, 1, 2, 3, 3, 4, 3, 4, 4, 4, 3, 3, 4, 4, 3, 2, 3, 4, 4, 3, 2, 3, 3, 3, 2, 3, 2, 2, 1, 2, 3, 3, 4, 3, 4, 4, 4, 3, 4, 5, 5, 4, 3, 4, 5, 5, 4, 4, 5, 5, 5, 4, 5, 4, 4, 3, 3, 4, 4, 5, 4, 5, 5, 5, 4, 3, 4, 4, 3, 2, 3, 4, 4, 3, 4
Offset: 0

Views

Author

Rémy Sigrist, Mar 17 2024

Keywords

Comments

Leading zeros are ignored.
Every positive integers occurs infinitely many times.

Examples

			The first terms, alongside the balanced ternary expansion of n, are:
  n    a(n)  bter(n)
  ---  ----  -------
    0     0        0
    1     1        1
    2     2       1T
    3     2       10
    4     1       11
    5     2      1TT
    6     3      1T0
    7     3      1T1
    8     3      10T
    9     2      100
   10     3      101
   11     2      11T
   12     2      110
   13     1      111
   14     2     1TTT
   15     3     1TT0
		

Crossrefs

Programs

  • PARI
    a(n) = { my (r = 0, d); while (n, r++; d = centerlift(Mod(n, 3)); while (d==centerlift(Mod(n, 3)), n = (n-d)/3;);); return (r); }

Formula

a(n) <= A134021(n).
a(A153773(k)) = k for any k > 0.