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.

A348534 Number of permutations p of [n] whose absolute differences between consecutive elements yield up-down sequences.

This page as a plain text file.
%I A348534 #39 Mar 07 2022 07:54:27
%S A348534 1,1,2,2,8,20,82,326,1678,8776,54804,357910,2646340,20551986,
%T A348534 176420758,1586656630,15504954504,158675287132,1738817196038,
%U A348534 19931418239724,242312687882510
%N A348534 Number of permutations p of [n] whose absolute differences between consecutive elements yield up-down sequences.
%C A348534 Number of permutations p of [n] such that |p(i-1)-p(i)| < |p(i)-p(i+1)| if i is even and |p(i-1)-p(i)| > |p(i)-p(i+1)| if i is odd.
%H A348534 Wikipedia, <a href="https://en.wikipedia.org/wiki/Permutation">Permutation</a>
%e A348534 a(0) = 1: (), the empty permutation.
%e A348534 a(1) = 1: 1.
%e A348534 a(2) = 2: 12, 21.
%e A348534 a(3) = 2: 213, 231.
%e A348534 a(4) = 8: 1243, 2134, 2143, 2413, 3142, 3412, 3421, 4312.
%e A348534 a(5) = 20: 12435, 12453, 21435, 21453, 23541, 31425, 31452, 31542, 32451, 32541, 34125, 34215, 35124, 35214, 35241, 43125, 45213, 45231, 54213, 54231.
%e A348534 a(6) = 82: 124356, 124365, 125364, 125634, ..., 652143, 652413, 653412, 653421.
%p A348534 b:= proc(s, x, y) option remember; (n-> `if`(n=0, 1, add((d->
%p A348534      `if`(x=0 or n::even and x<d or n::odd and x>d, b(s minus {j},
%p A348534      `if`(y=0, 0, d), j), 0))(abs(y-j)), j=s)))(nops(s))
%p A348534     end:
%p A348534 a:= n-> b({$1..n}, 0$2):
%p A348534 seq(a(n), n=0..12);
%t A348534 b[s_, x_, y_] := b[s, x, y] = Function[n, If[n == 0, 1, Sum[Function[d,
%t A348534      If[x == 0 || EvenQ[n] && x < d || OddQ[n] && x > d, b[s ~Complement~
%t A348534      {j}, If[y == 0, 0, d], j], 0]][Abs[y - j]], {j, s}]]][Length[s]];
%t A348534 a[n_] := b[Range[n], 0, 0];
%t A348534 Table[a[n], {n, 0, 12}] (* _Jean-François Alcover_, Mar 07 2022, after _Alois P. Heinz_ *)
%Y A348534 Cf. A295370, A338738.
%K A348534 nonn,more
%O A348534 0,3
%A A348534 _Alois P. Heinz_, Oct 25 2021