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.

A330168 Length of the longest run of 2's in the ternary expression of n.

This page as a plain text file.
%I A330168 #17 Jan 24 2020 14:11:21
%S A330168 0,0,1,0,0,1,1,1,2,0,0,1,0,0,1,1,1,2,1,1,1,1,1,1,2,2,3,0,0,1,0,0,1,1,
%T A330168 1,2,0,0,1,0,0,1,1,1,2,1,1,1,1,1,1,2,2,3,1,1,1,1,1,1,1,1,2,1,1,1,1,1,
%U A330168 1,1,1,2,2,2,2,2,2,2,3,3,4,0,0,1,0,0,1,1,1,2,0
%N A330168 Length of the longest run of 2's in the ternary expression of n.
%C A330168 All numbers appear in this sequence. Numbers of the form 3^n-1 (A024023(n)) have n 2's in their ternary expression.
%C A330168 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 2 in its ternary expression.
%H A330168 Wikipedia, <a href="https://en.wikipedia.org/wiki/Ternary_numeral_system">Ternary numeral system</a>.
%F A330168 a(A024023(n)) = a(3^n-1) = n.
%F A330168 a(n) = 0 iff n is in A005836.
%e A330168 For n = 74, the ternary expression of 74 is 2202. The length of the runs of 2's in the ternary expression of 74 are 2 and 1, respectively. The larger of these two values is 2, so a(74) = 2.
%e A330168    n [ternary n] a(n)
%e A330168    0 [        0] 0
%e A330168    1 [        1] 0
%e A330168    2 [        2] 1
%e A330168    3 [      1 0] 0
%e A330168    4 [      1 1] 0
%e A330168    5 [      1 2] 1
%e A330168    6 [      2 0] 1
%e A330168    7 [      2 1] 1
%e A330168    8 [      2 2] 2
%e A330168    9 [    1 0 0] 0
%e A330168   10 [    1 0 1] 0
%e A330168   11 [    1 0 2] 1
%e A330168   12 [    1 1 0] 0
%e A330168   13 [    1 1 1] 0
%e A330168   14 [    1 1 2] 1
%e A330168   15 [    1 2 0] 1
%e A330168   16 [    1 2 1] 1
%e A330168   17 [    1 2 2] 2
%e A330168   18 [    2 0 0] 1
%e A330168   19 [    2 0 1] 1
%e A330168   20 [    2 0 2] 1
%t A330168 Table[Max@FoldList[If[#2==2,#1+1,0]&,0,IntegerDigits[n,3]],{n,0,90}]
%Y A330168 Cf. A007089, A024023, A081603, A330036, A330166, A330167.
%Y A330168 Equals zero iff n is in A005836.
%K A330168 nonn,base
%O A330168 0,9
%A A330168 _Joshua Oliver_, Dec 04 2019