login
A332025
Sum of the lengths of the longest runs of 0, 1, and 2 in the ternary expression of n.
0
1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 2, 3, 3, 3, 4, 3, 4, 2, 3, 3, 3, 3, 4, 4, 3, 4, 4, 4, 4, 4, 3, 4, 4, 3, 3, 3, 3, 2, 4, 3, 4, 4, 4, 3, 3, 4, 3, 2, 3, 3, 4, 3, 3, 4, 4, 3, 3, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4, 4, 5, 4, 5, 3, 4, 4, 4, 4, 5, 3
OFFSET
0,4
COMMENTS
All positive integers appear in this sequence. Given some number k, there will always be some ternary number that has k 1's or k 2's.
The number 0 never appears in this sequence, as every number has at least 1 digit.
FORMULA
a(n) = A330166(n) + A330167(n) + A330168(n).
a(A003462(n)) = a(A024023(n)) = n.
EXAMPLE
For n = 268, the ternary expansion of 268 is 100221. The length of the run of 0's in the ternary expansion of 268 is 2. The length of the runs of 1's in the ternary expansion of 268 are 1 and 1 respectively. The length of the run of 2's in the ternary expansion of 268 is 2. The sum of 2, 1, and 2 is 5, so a(268) = 5.
n [ternary n] A330166(n) + A330167(n) + A330168(n) = a(n)
0 [ 0] 1 + 0 + 0 = 1
1 [ 1] 0 + 1 + 0 = 1
2 [ 2] 0 + 0 + 1 = 1
3 [ 1 0] 1 + 1 + 0 = 2
4 [ 1 1] 0 + 2 + 0 = 2
5 [ 1 2] 0 + 1 + 1 = 2
6 [ 2 0] 1 + 0 + 1 = 2
7 [ 2 1] 0 + 1 + 1 = 2
8 [ 2 2] 0 + 0 + 2 = 2
9 [ 1 0 0] 2 + 1 + 0 = 3
10 [ 1 0 1] 1 + 1 + 0 = 2
11 [ 1 0 2] 1 + 1 + 1 = 3
12 [ 1 1 0] 1 + 2 + 0 = 3
13 [ 1 1 1] 0 + 3 + 0 = 3
14 [ 1 1 2] 0 + 2 + 1 = 3
15 [ 1 2 0] 1 + 1 + 1 = 3
16 [ 1 2 1] 0 + 1 + 1 = 2
17 [ 1 2 2] 0 + 1 + 2 = 3
18 [ 2 0 0] 2 + 0 + 1 = 3
19 [ 2 0 1] 1 + 1 + 1 = 3
20 [ 2 0 2] 1 + 0 + 1 = 2
MATHEMATICA
Table[Sum[Max@FoldList[If[#2==k, #1+1, 0]&, 0, IntegerDigits[n, 3]], {k, 0, 2}], {n, 1, 90}]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Joshua Oliver, Feb 05 2020
STATUS
approved