login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A330168 Length of the longest run of 2's in the ternary expression of n. 3
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, 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, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 0, 0, 1, 0, 0, 1, 1, 1, 2, 0 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,9

COMMENTS

All numbers appear in this sequence. Numbers of the form 3^n-1 (A024023(n)) have n 2's in their ternary expression.

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.

LINKS

Table of n, a(n) for n=0..90.

Wikipedia, Ternary numeral system.

FORMULA

a(A024023(n)) = a(3^n-1) = n.

a(n) = 0 iff n is in A005836.

EXAMPLE

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.

   n [ternary n] a(n)

   0 [        0] 0

   1 [        1] 0

   2 [        2] 1

   3 [      1 0] 0

   4 [      1 1] 0

   5 [      1 2] 1

   6 [      2 0] 1

   7 [      2 1] 1

   8 [      2 2] 2

   9 [    1 0 0] 0

  10 [    1 0 1] 0

  11 [    1 0 2] 1

  12 [    1 1 0] 0

  13 [    1 1 1] 0

  14 [    1 1 2] 1

  15 [    1 2 0] 1

  16 [    1 2 1] 1

  17 [    1 2 2] 2

  18 [    2 0 0] 1

  19 [    2 0 1] 1

  20 [    2 0 2] 1

MATHEMATICA

Table[Max@FoldList[If[#2==2, #1+1, 0]&, 0, IntegerDigits[n, 3]], {n, 0, 90}]

CROSSREFS

Cf. A007089, A024023, A081603, A330036, A330166, A330167.

Equals zero iff n is in A005836.

Sequence in context: A147645 A091970 A093955 * A081603 A273513 A330005

Adjacent sequences:  A330165 A330166 A330167 * A330169 A330170 A330171

KEYWORD

nonn,base

AUTHOR

Joshua Oliver, Dec 04 2019

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 10 22:21 EDT 2021. Contains 342856 sequences. (Running on oeis4.)