cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A361648 Number of permutations p of [n] such that p(i), p(i+2), p(i+4),... form an up-down sequence for i in {1,2}.

This page as a plain text file.
%I A361648 #28 Dec 06 2023 14:44:21
%S A361648 1,1,2,3,6,20,80,350,1750,10080,64512,450912,3438204,28471872,
%T A361648 253913088,2424193200,24687555750,267199961600,3062092267520,
%U A361648 37037541651968,471565937953396,6304419553216512,88298062293762048,1292879475255280640,19753693667117055100
%N A361648 Number of permutations p of [n] such that p(i), p(i+2), p(i+4),... form an up-down sequence for i in {1,2}.
%C A361648 Number of permutations p of [n] such that p(i) < p(i+2) > p(i+4) < ... for i <= 2.
%H A361648 Alois P. Heinz, <a href="/A361648/b361648.txt">Table of n, a(n) for n = 0..485</a>
%F A361648 a(n) = A000111(floor(n/2))*A000111(ceiling(n/2))*A001405(n).
%e A361648 a(0) = 1: (), the empty permutation.
%e A361648 a(1) = 1: 1.
%e A361648 a(2) = 2: 12, 21.
%e A361648 a(3) = 3: 123, 132, 213.
%e A361648 a(4) = 6: 1234, 1243, 1324, 2134, 2143, 3142.
%e A361648 a(5) = 20: 12453, 12534, 12543, 13452, 13542, 14352, 21453, 21534, 21543, 23451, 23541, 24351, 31452, 31524, 31542, 32451, 32541, 41523, 41532, 42531.
%e A361648 a(6) = 80: 124635, 125634, 125643, 126453, ..., 526413, 526431, 536412, 536421.
%p A361648 b:= proc(u, o) option remember; `if`(u+o=0, 1,
%p A361648       add(b(o-1+j, u-j), j=1..u))
%p A361648     end:
%p A361648 a:= n-> (h-> b(h, 0)*b(n-h, 0)*binomial(n, h))(iquo(n, 2)):
%p A361648 seq(a(n), n=0..30);
%t A361648 b[u_, o_] := b[u, o] = If[u+o == 0, 1, Sum[b[o-1+j, u-j], {j, 1, u}]];
%t A361648 a[n_] := With[{h = Quotient[n, 2]}, b[h, 0] b[n-h, 0] Binomial[n, h]];
%t A361648 Table[a[n], {n, 0, 30}] (* _Jean-François Alcover_, Nov 26 2023, after _Alois P. Heinz_ *)
%o A361648 (Python)
%o A361648 from math import comb
%o A361648 from itertools import accumulate
%o A361648 def A361648(n):
%o A361648     if n<=1:
%o A361648         return 1
%o A361648     blist = (0,1)
%o A361648     for _ in range((m:=n>>1)-1):
%o A361648         blist = tuple(accumulate(reversed(blist),initial=0))
%o A361648     return blist[-1]*sum(blist)*comb(n,m) if n&1 else blist[-1]**2*comb(n,m) # _Chai Wah Wu_, Apr 16 2023
%Y A361648 Column k=2 of A361651.
%Y A361648 Cf. A000111, A000142, A001405.
%K A361648 nonn
%O A361648 0,3
%A A361648 _Alois P. Heinz_, Mar 19 2023