login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A371275
a(n) is the number of runs in the balanced ternary expansion of n.
0
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,3
COMMENTS
Leading zeros are ignored.
Every positive integers occurs infinitely many times.
FORMULA
a(n) <= A134021(n).
a(A153773(k)) = k for any k > 0.
EXAMPLE
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
PROG
(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); }
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Mar 17 2024
STATUS
approved