A328378 Number of permutations of length n that possess the maximal sum of distances between contiguous elements.
1, 1, 2, 4, 2, 8, 8, 48, 72, 576, 1152, 11520, 28800, 345600, 1036800, 14515200, 50803200, 812851200, 3251404800, 58525286400, 263363788800, 5267275776000, 26336378880000, 579400335360000, 3186701844480000, 76480844267520000, 458885065605120000, 11931011705733120000
Offset: 0
Keywords
Examples
(1,3,2) is a permutation of length 3 with distance sum |1-3| + |3-2| = 2 + 1 = 3. For n = 3, the 4 permutations with maximum sum of distances are (1,3,2), (2,1,3), (2,3,1) and (3,1,2).
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..508
- Tomás Roca Sánchez, Github Python program along with explanations.
Crossrefs
Programs
-
Mathematica
A328378[n_]:=If[n<2,1,2(Floor[n/2]-1)!^2If[Divisible[n,2],1,n-1]];Array[A328378,30,0] (* Paolo Xausa, Aug 13 2023 *)
-
PARI
a(n)={if(n<2, n>=0, 2*(n\2-1)!^2*if(n%2, n-1, 1))} \\ Andrew Howroyd, Oct 16 2019
-
Python
# See Github link
Formula
a(2*n) = 2*(n-1)!^2 for n > 0; a(2*n+1) = 4*n!*(n-1)! for n > 0. - Andrew Howroyd, Oct 16 2019
D-finite with recurrence: - (12*n-20)*a(n) + 4*a(n-1) + (3*n-2)*(n-3)*(n-2)*a(n-2) = 0. - Georg Fischer, Nov 25 2022
Sum_{n>=0} 1/a(n) = BesselI(0, 2)/2 + BesselI(1, 2)/4 + 2 = A070910/2 + A096789/4 + 2. - Amiram Eldar, Oct 03 2023
Extensions
Terms a(12) and beyond from Andrew Howroyd, Oct 16 2019
Comments