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!)
A338765 Number of permutations p of [n] such that | |p(i) - p(i-1)| - |p(i+1) - p(i)| | <= 1. 2
1, 1, 2, 6, 18, 38, 76, 162, 330, 650, 1272, 2586, 5262, 10506, 20856, 41928, 83684, 165800, 329310, 653614, 1303388, 2584660, 5139580, 10210912, 20288128, 40224174, 79824572, 158316222, 314272812 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

LINKS

Table of n, a(n) for n=0..28.

Wikipedia, Permutation

MAPLE

b:= proc(s, x, y) option remember; `if`(s={}, 1, add(

      `if`(x=0 or y=0 or abs(abs(x-y)-abs(y-j))<=1,

         b(s minus {j}, y, j), 0), j=s))

    end:

a:= n-> b({$1..n}, 0$2):

seq(a(n), n=0..15);

MATHEMATICA

b[s_, x_, y_] := b[s, x, y] = If[s == {}, 1, Sum[

     If[x == 0 || y == 0 || Abs[Abs[x - y] - Abs[y - j]] <= 1,

     b[s ~Complement~ {j}, y, j], 0], {j, s}]];

a[n_] := b[Range[n], 0, 0];

a /@ Range[0, 15] (* Jean-Fran├žois Alcover, Apr 26 2021, after Alois P. Heinz *)

CROSSREFS

Cf. A295370 A338766.

Sequence in context: A064842 A302647 A324580 * A339149 A101695 A014741

Adjacent sequences:  A338762 A338763 A338764 * A338766 A338767 A338768

KEYWORD

nonn,more

AUTHOR

Alois P. Heinz, Nov 07 2020

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 24 00:05 EST 2022. Contains 350515 sequences. (Running on oeis4.)