OFFSET

1,3

COMMENTS

Every other base-3 digit must be strictly less than its neighbors. - M. F. Hasler, Oct 05 2018

The terms can be generated in the following way: if A(n) are the terms with n digits in base 3, the terms with n+2 digits are obtained by prefixing them with '10' and with '20', and prefixing '21' to those starting with a digit '2'. It is easy to prove that #A(n) = A000045(n+2), since from the above we have #A(n+2) = 2*#A(n) + #A(n-1) = #A(n) + #A(n+1). (The #A(n-1) numbers starting with '2' are #A(n-2) numbers prefixed with '20' and #A(n-3) prefixed with '21'.) - M. F. Hasler, Oct 05 2018

LINKS

M. F. Hasler, Table of n, a(n) for n = 1..5000

FORMULA

EXAMPLE

The base-3 representation of the initial terms is 0, 1, 2, 10, 20, 21, 101, 102, 201, 202, 212, 1010, 1020, 1021, 2010, 2020, 2021, 2120, 2121, 10101, 10102, ...

MATHEMATICA

sdQ[n_]:=Module[{s=Sign[Differences[IntegerDigits[n, 3]]]}, s==PadRight[{}, Length[s], {-1, 1}]]; Select[Range[0, 700], sdQ] (* Vincenzo Librandi, Oct 06 2018 *)

PROG

(PARI) is(n, b=3)=!for(i=2, #n=digits(n, b), (n[i-1]-n[i])*(-1)^i>0||return) \\ M. F. Hasler, Oct 05 2018

CROSSREFS

KEYWORD

nonn,base

AUTHOR

EXTENSIONS

Definition edited, cross-references and a(1) = 0 inserted by M. F. Hasler, Oct 05 2018

STATUS

approved