A330167 Length of the longest run of 1's in the ternary expression of n.
0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 1, 1, 2, 3, 2, 1, 1, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 1, 1, 2, 3, 2, 1, 1, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1
Offset: 0
Examples
For n = 43, the ternary expression of 43 is 1121. The length of the runs of 1's in the ternary expression of 43 are 2 and 1, respectively. The larger of these two values is 2, so a(43) = 2. n [ternary n] a(n) 0 [ 0] 0 1 [ 1] 1 2 [ 2] 0 3 [ 1 0] 1 4 [ 1 1] 2 5 [ 1 2] 1 6 [ 2 0] 0 7 [ 2 1] 1 8 [ 2 2] 0 9 [ 1 0 0] 1 10 [ 1 0 1] 1 11 [ 1 0 2] 1 12 [ 1 1 0] 2 13 [ 1 1 1] 3 14 [ 1 1 2] 2 15 [ 1 2 0] 1 16 [ 1 2 1] 1 17 [ 1 2 2] 1 18 [ 2 0 0] 0 19 [ 2 0 1] 1 20 [ 2 0 2] 0
Links
- Wikipedia, Ternary numeral system.
Crossrefs
Programs
-
Mathematica
Table[Max@FoldList[If[#2==1,#1+1,0]&,0,IntegerDigits[n,3]],{n,0,90}] Table[Max[Length/@Select[Split[IntegerDigits[n,3]],MemberQ[#,1]&]],{n,0,100}]/.(-\[Infinity]->0) (* Harvey P. Dale, Jan 07 2023 *)
Comments