OFFSET
0,3
COMMENTS
These are permutations of n whose second-differences are nonzero. - Gus Wiseman, Jun 03 2019
LINKS
EXAMPLE
a(3) = 4: 132, 213, 231, 312.
a(4) = 18: 1243, 1324, 1342, 1423, 2134, 2143, 2314, 2413, 2431, 3124, 3142, 3241, 3412, 3421, 4132, 4213, 4231, 4312.
MAPLE
b:= proc(s, j, k) option remember; `if`(s={}, 1,
add(`if`(k=0 or 2*j<>i+k, b(s minus {i}, i,
`if`(2*i-j in s, j, 0)), 0), i=s))
end:
a:= n-> b({$1..n}, 0$2):
seq(a(n), n=0..12);
MATHEMATICA
Table[Length[Select[Permutations[Range[n]], !MemberQ[Differences[#, 2], 0]&]], {n, 0, 5}] (* Gus Wiseman, Jun 03 2019 *)
b[s_, j_, k_] := b[s, j, k] = If[s == {}, 1, Sum[If[k == 0 || 2*j != i + k, b[s~Complement~{i}, i, If[MemberQ[s, 2*i - j ], j, 0]], 0], {i, s}]];
a[n_] := a[n] = b[Range[n], 0, 0];
Table[Print[n, " ", a[n]]; a[n], {n, 0, 16}] (* Jean-François Alcover, Nov 20 2023, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Nov 20 2017
EXTENSIONS
a(22)-a(23) from Vaclav Kotesovec, Mar 22 2022
STATUS
approved