OFFSET
0,3
COMMENTS
a(n) = A152874(n,1).
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..506
FORMULA
a(2n) = 2n!^2; a(2n+1) = 2n!(n+1)! (for n>=2).
E.g.f.: 1+x+2*(4*sqrt(4-x^2)*arcsin(x/2) - 4x + 4x^2 + x^3 - x^4)/((2+x)*(2-x)^2).
D-finite with recurrence 4*a(n) -2*a(n-1) -n*(n-1)*a(n-2)=0. - R. J. Mathar, Jul 22 2022
EXAMPLE
a(4)=8 because we have 1324, 1342, 3124, 3142, 2413, 2431, 4213 and 4231.
MAPLE
a := proc (n) if `mod`(n, 2) = 0 then 2*factorial((1/2)*n)^2 else 2*factorial((1/2)*n-1/2)*factorial((1/2)*n+1/2) end if end proc: seq(a(n), n = 2 .. 25);
# second Maple program:
a:= n-> (h-> 2^signum(h)*h!*(n-h)!)(iquo(n, 2)):
seq(a(n), n=0..27); # Alois P. Heinz, May 23 2023
# third Maple program:
a:= proc(n) option remember; `if`(n<4, n*(n-1)/2+1,
n*(n-1)*a(n-2)/4 +a(n-1)/2)
end:
seq(a(n), n=0..27); # Alois P. Heinz, May 23 2023
MATHEMATICA
a[n_] := Which[n<2, 1, EvenQ[n], 2(n/2)!^2, True, 2((n-1)/2)!*((n+1)/2)!];
Table[a[n], {n, 0, 27}] (* Jean-François Alcover, Aug 16 2023 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Emeric Deutsch, Dec 15 2008
EXTENSIONS
a(0)=a(1)=1 prepended by Alois P. Heinz, May 23 2023
STATUS
approved