login
Number of permutations sigma of [n] such that i! divides Product_{k=1..i} sigma(k) for 1 <= i <= n.
3

%I #65 Feb 25 2024 18:54:36

%S 1,1,2,4,14,28,212,424,3060,13488,131212,262424,6444376,12888752,

%T 145241952,2146993212,40313750564,80627501128,2265599072684,

%U 4531198145368,173216179971224,3202520631881824,42018513097187068,84037026194374136,7051753589203676704,50056536119264986708

%N Number of permutations sigma of [n] such that i! divides Product_{k=1..i} sigma(k) for 1 <= i <= n.

%F a(p) = 2*a(p-1) if p is prime.

%e a(4) = 14: 1234, 1432, 2134, 2314, 2341, 2431, 3214, 3241, 3412, 3421, 4132, 4231, 4312, 4321.

%e a(5) = 28: 12345, 14325, 21345, 23145, 23415, 23451, 23541, 24315, 24351, 25341, 32145, 32415, 32451, 32541, 34125, 34215, 34251, 34521, 41325, 42315, 42351, 43125, 43215, 43251, 43521, 45321, 52341, 54321.

%p b:= proc(s, p) option remember; (n-> `if`(n=0, 1, add(`if`(

%p irem(p*n, j, 'q')=0, b(s minus {j}, q), 0), j=s)))(nops(s))

%p end:

%p a:= n-> b({$1..n}, 1):

%p seq(a(n), n=0..17); # _Alois P. Heinz_, Apr 09 2020

%t b[s_, p_] := b[s, p] = Module[{n=Length[s], q, r}, If[n==0, 1, Sum[If[{q, r} = QuotientRemainder[p n, j]; r==0, b[s~Complement~{j}, q], 0], {j, s}]]];

%t a[n_] := a[n] = If[n>2 && PrimeQ[n], 2 a[n-1], b[Range[n], 1]];

%t Table[Print[n, " ", a[n]]; a[n], {n, 0, 25}] (* _Jean-François Alcover_, Nov 16 2020, after _Alois P. Heinz_ *)

%o (PARI) {a(n) = if(n==0, 1, my(k=0); forperm([1..n], p, if(#Set(vector(n, i, prod(j=1, i, p[j])%i!))==1, k++)); k)}

%Y Cf. A263987, A320843, A333892.

%K nonn

%O 0,3

%A _Seiichi Manyama_, Apr 09 2020

%E a(14)-a(25) from _Alois P. Heinz_, Apr 09 2020