%I #14 Oct 31 2021 13:46:21
%S 0,0,0,3,15,86,544,3934,32079,292509,2952702,32712087,394749367,
%T 5155010088,72440184064,1090017765544,17486996858151,297965879586295,
%U 5374189975316350,102290550351854445,2049025241258716927,43089888746430771294,949172134240270646352
%N Number of permutations p of [n] having at least one index i with |p(i)-i| = 2.
%H Alois P. Heinz, <a href="/A306524/b306524.txt">Table of n, a(n) for n = 0..450</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Permutation">Permutation</a>
%F a(n) = n! - A306523(n).
%e a(3) = 3: 231, 312, 321.
%e a(4) = 15: 1342, 1423, 1432, 2314, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4132, 4213, 4312.
%t T[n_, k_] := n! - Permanent[Table[If[Abs[i-j] == k, 0, 1], {i, 1, n}, {j, 1, n}]];
%t a[n_] := If[n == 0, 0, T[n, 2]];
%t Table[Print[n, " ", a[n]]; a[n], {n, 0, 23}] (* _Jean-François Alcover_, Oct 31 2021, after _Alois P. Heinz_ in A306506 *)
%Y Column k=2 of A306506.
%Y Cf. A000142, A306523.
%K nonn
%O 0,4
%A _Alois P. Heinz_, Feb 21 2019