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.
%I A381461 #25 Mar 11 2025 15:26:10 %S A381461 1,0,0,0,0,0,2,8,115,1274,15099,179628,2260064,30534802,441269110, %T A381461 6789665680,110947884520,1920180939650,35099424286573,675866037989156, %U A381461 13676799446869485,290208293166279344,6443880771921767240 %N A381461 Number of permutations of [n] with no fixed points where adjacent elements differ by at least 3. %H A381461 Robert P. P. McKone, <a href="/A381461/a381461_1.txt">The permutations n=6 to n=11</a>. %H A381461 Wikipedia, <a href="https://en.wikipedia.org/wiki/Permutation">Permutation</a> %e A381461 a(6) = 2: 362514, 415263. %e A381461 a(7) = 8: 2516374, 3615274, 3625174, 3627415, 3741625, 4152736, 4163725, 4173625. %e A381461 a(8) = 115: 25163847, 25174836, 25184736, 25814736, ..., 84736251, 85263714, 85263741, 85274163. %p A381461 b:= proc(s, l) option remember; (n-> `if`(n=0, 1, add( %p A381461 `if`(j=n or abs(l-j)<3, 0, b(s minus {j}, j)), j=s)))(nops(s)) %p A381461 end: %p A381461 a:= n-> b({$1..n}, -2): %p A381461 seq(a(n), n=0..16); %t A381461 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 *) %Y A381461 Cf. A000166, A002464, A127697, A288208. %K A381461 nonn,more %O A381461 0,7 %A A381461 _Alois P. Heinz_, Feb 24 2025