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.

A330167 Length of the longest run of 1's in the ternary expression of n.

This page as a plain text file.
%I A330167 #19 Jan 07 2023 11:30:16
%S A330167 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,
%T A330167 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,
%U A330167 2,1,1,1,0,1,0,1,2,1,0,1,0,1,1,1,1,2,1,1,1,1,1
%N A330167 Length of the longest run of 1's in the ternary expression of n.
%C A330167 All numbers appear in this sequence. Numbers of the form (3^n-1)/2 (A003462(n)) have n 1's in their ternary expression.
%C A330167 The longest run of zeros possible in this sequence is 2, as the last digit of the ternary expression of the integers cycles between 0, 1, and 2, meaning that at least one of three consecutive numbers has a 1 in its ternary expression.
%H A330167 Wikipedia, <a href="https://en.wikipedia.org/wiki/Ternary_numeral_system">Ternary numeral system</a>.
%F A330167 a(A003462(n)) = a((3^n-1)/2) = n.
%F A330167 a(n) = 0 iff n is in A005823.
%e A330167 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.
%e A330167    n [ternary n] a(n)
%e A330167    0 [        0] 0
%e A330167    1 [        1] 1
%e A330167    2 [        2] 0
%e A330167    3 [      1 0] 1
%e A330167    4 [      1 1] 2
%e A330167    5 [      1 2] 1
%e A330167    6 [      2 0] 0
%e A330167    7 [      2 1] 1
%e A330167    8 [      2 2] 0
%e A330167    9 [    1 0 0] 1
%e A330167   10 [    1 0 1] 1
%e A330167   11 [    1 0 2] 1
%e A330167   12 [    1 1 0] 2
%e A330167   13 [    1 1 1] 3
%e A330167   14 [    1 1 2] 2
%e A330167   15 [    1 2 0] 1
%e A330167   16 [    1 2 1] 1
%e A330167   17 [    1 2 2] 1
%e A330167   18 [    2 0 0] 0
%e A330167   19 [    2 0 1] 1
%e A330167   20 [    2 0 2] 0
%t A330167 Table[Max@FoldList[If[#2==1,#1+1,0]&,0,IntegerDigits[n,3]],{n,0,90}]
%t A330167 Table[Max[Length/@Select[Split[IntegerDigits[n,3]],MemberQ[#,1]&]],{n,0,100}]/.(-\[Infinity]->0) (* _Harvey P. Dale_, Jan 07 2023 *)
%Y A330167 Cf. A003462, A007089, A062756, A330036, A330166, A330168.
%Y A330167 Equals zero iff n is in A005823.
%K A330167 nonn,base
%O A330167 0,5
%A A330167 _Joshua Oliver_, Dec 04 2019