login
A371256
The run lengths transform of the ternary expansion of n corresponds to the run lengths transform of the binary expansion of a(n).
5
0, 1, 1, 2, 3, 2, 2, 2, 3, 4, 5, 5, 6, 7, 6, 5, 5, 4, 4, 5, 5, 5, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 10, 10, 10, 11, 12, 13, 13, 14, 15, 14, 13, 13, 12, 11, 10, 10, 10, 11, 10, 9, 9, 8, 8, 9, 9, 10, 11, 10, 10, 10, 11, 11, 10, 10, 9, 8, 9, 10, 10, 11, 12, 13, 13
OFFSET
0,4
COMMENTS
For any v >= 0, the value v appears 2^A005811(v) times in the sequence.
LINKS
FORMULA
a(A005823(n)) = n - 1.
a(A005836(n)) = n - 1.
a(A004488(n)) = a(n).
abs(a(n+1) - a(n)) <= 1.
EXAMPLE
The first terms, alongside the ternary expansion of n and the binary expansion of a(n), are:
n a(n) ter(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 1 2 1
3 2 10 10
4 3 11 11
5 2 12 10
6 2 20 10
7 2 21 10
8 3 22 11
9 4 100 100
10 5 101 101
11 5 102 101
12 6 110 110
13 7 111 111
14 6 112 110
15 5 120 101
PROG
(PARI) a(n) = { my (r = [], d, l, v = 0); while (n, d = n%3; l = 0; while ((n%3)==d, n\=3; l++; ); r = concat(l, r); ); for (k = 1, #r, v = (v+k%2)*2^r[k]-k%2); v }
CROSSREFS
See A371263 for a similar sequence.
Sequence in context: A185150 A299229 A289496 * A248973 A305048 A205717
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Mar 16 2024
STATUS
approved