%I #17 Sep 08 2022 08:46:21
%S 0,2,4,14,56,282,1692,11846,94768,852914,8529140,93820542,1125846504,
%T 14636004554,204904063756,3073560956342,49176975301472,
%U 836008580125026,15048154442250468,285914934402758894,5718298688055177880,120084272449158735482,2641853993881492180604
%N Row sums of A306015.
%C 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
%H G. C. Greubel, <a href="/A306150/b306150.txt">Table of n, a(n) for n = 0..448</a>
%F a(n) = e * Gamma(n + 1, 1) - !(n).
%F a(n) = Gamma(n + 1, 1) * e - Gamma(n + 1, -1) / e.
%F a(n) = n*a(n-1) + a(n-2) - (n-2)*a(n-3) for n >= 3.
%F a(n) = n! [x^n] 2*sinh(x)/(1-x).
%F a(n) = 2*A186763(n) = (-1)^(n+1)*2*A009628(n) = A000522(n) - A000166(n).
%p egf := 2*sinh(x)/(1-x): ser := series(egf,x,24):
%p seq(n!*coeff(ser,x,n), n=0..22);
%t Table[Exp[1] Gamma[n+1, 1] - Subfactorial[n], {n, 0, 22}]
%t With[{nmax = 50}, CoefficientList[Series[2*Sinh[x]/(1 - x), {x, 0, nmax}], x]*Range[0, nmax]!] (* _G. C. Greubel_, Jul 18 2018 *)
%o (Sage)
%o @cached_function
%o def a(n):
%o if n<3: return 2*n
%o return n*a(n-1)+a(n-2)-(n-2)*a(n-3)
%o [a(n) for n in (0..22)]
%o (PARI) x='x+O('x^30); concat([0], Vec(serlaplace(2*sinh(x)/(1 - x)))) \\ _G. C. Greubel_, Jul 18 2018
%o (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
%Y Cf. A000166, A000522, A009628, A186763.
%Y Cf. A306015.
%K nonn
%O 0,2
%A _Peter Luschny_, Jun 23 2018