login
Numbers with digits in {0,1,2} such that every other digit is strictly less than its neighbors.
7

%I #16 Oct 13 2018 12:34:17

%S 0,1,2,10,20,21,101,102,201,202,212,1010,1020,1021,2010,2020,2021,

%T 2120,2121,10101,10102,10201,10202,10212,20101,20102,20201,20202,

%U 20212,21201,21202,21212,101010,101020,101021,102010,102020,102021,102120,102121

%N Numbers with digits in {0,1,2} such that every other digit is strictly less than its neighbors.

%C Terms of A032858 written in base 3.

%C There are A000045(n+2) terms with n digits (where 0 is taken to have no digits), so the first term with n digits is at index A000071(n+3). See A032858 for the proof.

%F a(n) = A007089(A032858(n)).

%o (PARI) {A=[0,1,2]; F=[1,1]; for(n=0,4, F=[F[2],vecsum(F)]; for(k=1,3, T=max(k*10,21)*10^n; A=concat(A,apply(t->t+T,A[F[2]-1+if(k>2,F*[2,-1]~)..vecsum(F)-2]))));A}

%Y Cf. A306106 .. A306111 and A297147: analog for bases 3..9 and 10.

%Y Cf. A000045 (Fibonacci), A000071(n) = Sum(k=0..n-2,A45(k)) = A000045(n)-1.

%Y Cf. A032858 and A032859 .. A032865 for other bases 3..10.

%K nonn,base

%O 1,3

%A _M. F. Hasler_, Oct 05 2018