login
Number of permutations p of [n] satisfying Sum_{i=1..n} (p(i)-i)^2 = n*(n+1)/2.
2

%I #26 Dec 16 2025 16:41:14

%S 1,0,0,2,2,0,0,78,380,0,0,43106,230894,0,0,46470939,295990436,0,0,

%T 93486183164,677977634271,0,0,303816912226577,2444144451253085,0,0,

%U 1454786596073959830,12758706122701884626,0,0

%N Number of permutations p of [n] satisfying Sum_{i=1..n} (p(i)-i)^2 = n*(n+1)/2.

%C Number of permutations of [n] with "entropy" equal to n*(n+1)/2.

%F a(n) = A175929(n,n*(n+1)/4) if n in { A014601 }.

%F a(n) = 0 <=> n in { A042963 }.

%F a(n) = A179264(n) - A179266(n).

%e a(0) = 1: the empty permutation.

%e a(3) = 2: 231, 312.

%e a(4) = 2: 2413, 3142.

%e a(7) = 78: 1247653, 1265473, 1273654, 1275436, ..., 5143267, 5231476, 5312476, 5321467.

%e a(8) = 380: 12378564, 12378645, 12386745, 12457863, ..., 62135487, 62143587, 62314578, 63124578.

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

%p x^((n-j)^2)*b(s minus {j})), j=s)))(nops(s))

%p end:

%p a:= n-> coeff(b({$1..n}), x, n*(n+1)/2):

%p seq(a(n), n=0..12);

%Y Cf. A000217, A014601, A042963, A056876, A074378, A126972, A175929, A179264, A179266, A180111.

%Y Cf. A390749, A391664.

%K nonn,more

%O 0,4

%A _Alois P. Heinz_, Dec 11 2025