OFFSET
0,2
COMMENTS
a(n) is the number of nonderangements of size n in which each fixed point is colored red or blue. For example, with n = 3, the derangements are 231 and 312 and they don't count, the permutations 132, 321, 213 each have 1 fixed point and hence 2 colorings, and the identity 123 with 3 fixed points has 8 colorings, yielding a(3) = 3*2 + 8 = 14 colorings altogether. - David Callan, Dec 19 2021
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..448
FORMULA
MAPLE
egf := 2*sinh(x)/(1-x): ser := series(egf, x, 24):
seq(n!*coeff(ser, x, n), n=0..22);
MATHEMATICA
Table[Exp[1] Gamma[n+1, 1] - Subfactorial[n], {n, 0, 22}]
With[{nmax = 50}, CoefficientList[Series[2*Sinh[x]/(1 - x), {x, 0, nmax}], x]*Range[0, nmax]!] (* G. C. Greubel, Jul 18 2018 *)
PROG
(Sage)
@cached_function
def a(n):
if n<3: return 2*n
return n*a(n-1)+a(n-2)-(n-2)*a(n-3)
[a(n) for n in (0..22)]
(PARI) x='x+O('x^30); concat([0], Vec(serlaplace(2*sinh(x)/(1 - x)))) \\ G. C. Greubel, Jul 18 2018
(Magma) m:=30; R<x>:=PowerSeriesRing(Rationals(), m); b:= [0] cat Coefficients(R!(2*Sinh(x)/(1-x))); [Factorial(n-1)*b[n]: n in [1..m]]; // G. C. Greubel, Jul 18 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Jun 23 2018
STATUS
approved