A381461 Number of permutations of [n] with no fixed points where adjacent elements differ by at least 3.
1, 0, 0, 0, 0, 0, 2, 8, 115, 1274, 15099, 179628, 2260064, 30534802, 441269110, 6789665680, 110947884520, 1920180939650, 35099424286573, 675866037989156, 13676799446869485, 290208293166279344, 6443880771921767240
Offset: 0
Examples
a(6) = 2: 362514, 415263. a(7) = 8: 2516374, 3615274, 3625174, 3627415, 3741625, 4152736, 4163725, 4173625. a(8) = 115: 25163847, 25174836, 25184736, 25814736, ..., 84736251, 85263714, 85263741, 85274163.
Links
- Robert P. P. McKone, The permutations n=6 to n=11.
- Wikipedia, Permutation
Programs
-
Maple
b:= proc(s, l) option remember; (n-> `if`(n=0, 1, add( `if`(j=n or abs(l-j)<3, 0, b(s minus {j}, j)), j=s)))(nops(s)) end: a:= n-> b({$1..n}, -2): seq(a(n), n=0..16);
-
Mathematica
Clear[permCount]; permCount[s_, last_] := permCount[s, last] = Module[{n, j}, n = Length[s]; If[n == 0, 1, Total[Table[If[j == n || Abs[last - j] < 3, 0, permCount[Complement[s, {j}], j]], {j, s}]]]]; Table[permCount[Range[n], -2], {n, 0, 12}] (* Robert P. P. McKone, Mar 01 2025 *)