OFFSET
0,3
COMMENTS
Note for n<5 there are no such subsequences, so those values are trivially n!.
LINKS
Max Alekseyev, Table of n, a(n) for n = 0..100
Wayne M. Dymacek, Isaac Lambert and Kyle Parsons, Arithmetic Progressions in Permutations, 2012. [broken link]
EXAMPLE
For n=5 (0,2,4,1,3) is an example of a permutation with an i,i+2,i+4 triple. If we look at 0,2,4 as a block, then we have 3! ways to permute the triple with the remaining 1 & 3. Hence a(5) = 5! - 3! = 114.
MAPLE
b:= proc(s, x, y) option remember; `if`(s={}, 1, add(
`if`(x=0 or x-y<>2 or y-j<>2, b(s minus {j}, y, j), 0), j=s))
end:
a:= n-> b({$1..n}, 0$2):
seq(a(n), n=0..14); # Alois P. Heinz, Apr 13 2021
MATHEMATICA
b[s_, x_, y_] := b[s, x, y] = If[s == {}, 1, Sum[
If[x == 0 || x - y != 2 || y - j != 2,
b[s ~Complement~ {j}, y, j], 0], {j, s}]];
a[n_] := b[Range[n], 0, 0];
Table[a[n], {n, 0, 14}] (* Jean-François Alcover, Mar 02 2022, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Isaac Lambert, Mar 06 2010
EXTENSIONS
a(0)-a(4) and a(10)-a(11) moved from a duplicate entry based on the Dymacek et al. paper on Apr 13 2021
a(12)-a(22) from Alois P. Heinz, Apr 13 2021
STATUS
approved