OFFSET
1
COMMENTS
Together with A189816, this sequence completes the list of "type 3,3" sequences described at A189628.
Alternate definition: a(n) = 1 if the ternary representation of n-1 has at least one "2" in it. Otherwise, a(n) = 0. Partial sums are given by A081610. - Nathaniel Johnston, May 17 2011
From Gabriele Fici, Mar 10 2024: (Start)
Fixed point of the substitution 0->001, 1->111.
An example of a Rote sequence, that is, it has exactly 2m distinct contiguous subsequences of length m, for every m >= 1. For example, there are 6 contiguous subsequences of length 3, namely 001, 010, 011, 100, 110, 111. (End)
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..13122
Mazen Khodier, New Methods for Analyzing the Properties of Automatic Sequences, Master's Thesis, Univ. Waterloo (Canada 2026). See p. 27, Table 5.1.
Günter Rote, Sequences With Subword Complexity 2n, Journal of Number Theory, Volume 46, Issue 2, February 1994, pp. 196-213.
MATHEMATICA
PROG
(PARI) a(n)=if(n<6, n==3, if(n%3, a(n\3+1), 1)) \\ Charles R Greathouse IV, Aug 11 2011
(Scheme) (define (A189820 n) (cond ((= 1 n) 0) ((zero? (modulo n 3)) 1) (else (A189820 (+ 1 (/ (- n (modulo n 3)) 3)))))) ;; Antti Karttunen, Aug 18 2017
(Python)
from gmpy2 import digits
def A189820(n):
l = (s:=digits(n-2, 3)).find('2')
if l >= 0: s = s[:l]+'1'*(len(s)-l)
m = (t:=digits(n-1, 3)).find('2')
if m >= 0: t = t[:m]+'1'*(len(t)-m)
return 1+int(s, 2)-int(t, 2) # Chai Wah Wu, Dec 05 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Clark Kimberling, Apr 28 2011
EXTENSIONS
Typo in definition fixed by Reinhard Zumkeller, Aug 11 2011
STATUS
approved
