%I #35 Nov 01 2021 04:23:20
%S 1,1,2,2,8,4,32,4,96,244,1400,20,3988,12,256,1328,3107082,7900,
%T 4352004,2676,752280,4710724,23591664,672,79424164,51627164,4705224,
%U 802988332,25488756038104,47736592,1706618983956,826828
%N Number of permutations of [n] such that the product of the first k elements and the product of the last k elements are multiples of k! for all k in [n].
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Permutation">Permutation</a>
%e a(4) = 8: 1234, 1432, 2134, 2314, 2341, 4132, 4312, 4321.
%e a(5) = 4: 12345, 14325, 52341, 54321.
%e a(7) = 4: 1234567, 1654327, 7234561, 7654321.
%e a(13) = 12: 123456789(10)(11)(12)(13), 143256789(10)(11)(12)(13), 143(10)987652(11)(12)(13), 1(12)(11)256789(10)34(13), 1(12)(11)(10)98765234(13), 1(12)(11)(10)98765432(13), (13)23456789(10)(11)(12)1, (13)43256789(10)(11)(12)1, (13)43(10)987652(11)(12)1, (13)(12)(11)256789(10)341, (13)(12)(11)(10)987652341, (13)(12)(11)(10)987654321.
%p b:= proc(s, n) option remember; (m-> `if`(m=0, 1, `if`(irem(
%p mul(h, h=({$1..n} minus s)), (n-m)!)=0 and irem(mul(h,
%p h=s), m!)=0, add(b(s minus {j}, n), j=s), 0)))(nops(s))
%p end:
%p a:= n-> b({$1..n}, n):
%p seq(a(n), n=0..17);
%t b[s_, n_] := b[s, n] = With[{m = Length[s]}, If[m == 0, 1, If[Mod[ Product[h, {h, Range[n] ~Complement~ s}], (n-m)!] == 0 && Mod[Times@@s, m!] == 0, Sum[b[s ~Complement~ {j}, n], {j, s}], 0]]];
%t a[n_] := b[Range[n], n];
%t Table[Print[n, " ", a[n]]; a[n], {n, 0, 27}] (* _Jean-François Alcover_, Nov 01 2021, after _Alois P. Heinz_ *)
%Y Cf. A000142, A333710, A333934.
%K nonn
%O 0,3
%A _Alois P. Heinz_, Apr 09 2020