The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A242785 Number of permutations of [n] avoiding the consecutive step pattern given by the binary expansion of n, where 1=up and 0=down. 4

%I #11 Mar 23 2021 16:13:07

%S 1,1,2,5,21,70,450,4326,34944,209863,1573632,21824925,302273664,

%T 2854894485,60269056512,1207441809209,19346879737625,252773481889854,

%U 2918333808555034,69792946997645295,982945842995115000,16085109561896603059,402131210857811703926

%N Number of permutations of [n] avoiding the consecutive step pattern given by the binary expansion of n, where 1=up and 0=down.

%H Alois P. Heinz, <a href="/A242785/b242785.txt">Table of n, a(n) for n = 0..150</a>

%e a(4) = 21 because there are 4! = 24 permutations of {1,2,3,4} and only 3 of them do not avoid the consecutive step pattern up, down, down given by the binary expansion of 4 = 100_2: (1,4,3,2), (2,4,3,1), (3,4,2,1).

%p a:= proc(n) option remember; local b, m, r, h;

%p if n<2 then return 1 fi;

%p m:= iquo(n, 2, 'r'); h:= 2^ilog2(n);

%p b:= proc(u, o, t) option remember; `if`(u+o=0, 1,

%p `if`(t=m and r=0, 0, add(b(u-j, o+j-1, irem(2*t, h)), j=1..u))+

%p `if`(t=m and r=1, 0, add(b(u+j-1, o-j, irem(2*t+1, h)), j=1..o)))

%p end; forget(b);

%p b(n, 0, 0)

%p end:

%p seq(a(n), n=0..30);

%t a[n_] := a[n] = Module[{b, m, r, h},

%t If[n < 2, Return[1]]; {m, r} = QuotientRemainder[n, 2];

%t h = 2^(Length@IntegerDigits[n, 2] - 1);

%t b[u_, o_, t_] := b[u, o, t] = If[u + o == 0, 1,

%t If[t == m && r == 0, 0,

%t Sum[b[u - j, o + j - 1, Mod[2t, h]], {j, 1, u}]] +

%t If[t == m && r == 1, 0,

%t Sum[b[u + j - 1, o - j, Mod[2t+1, h]], {j, 1, o}]]];

%t b[n, 0, 0]];

%t a /@ Range[0, 30] (* _Jean-François Alcover_, Mar 23 2021, after _Alois P. Heinz_ *)

%Y Column k=0 of A242783.

%Y Main diagonal of A242784.

%Y Cf. A335308.

%K nonn

%O 0,3

%A _Alois P. Heinz_, May 22 2014

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 14 21:33 EDT 2024. Contains 372533 sequences. (Running on oeis4.)