%I #29 Sep 08 2022 08:44:59
%S 3,3,5,13,49,241,1441,10081,80641,725761,7257601,79833601,958003201,
%T 12454041601,174356582401,2615348736001,41845579776001,
%U 711374856192001,12804747411456001,243290200817664001
%N 2*n! + 1.
%H Vincenzo Librandi, <a href="/A052898/b052898.txt">Table of n, a(n) for n = 0..200</a>
%H INRIA Algorithms Project, <a href="http://ecs.inria.fr/services/structure?nbr=874">Encyclopedia of Combinatorial Structures 874</a>
%F E.g.f.: (-2-exp(x)+x*exp(x))/(-1+x).
%F Recurrence: {a(2)=5, a(1)=3, (n^2+2*n+1)*a(n)+(-n^2-3*n-1)*a(n+1)+a(n+2)*n}
%F From _Sergei N. Gladkovskii_, Jul 04 2012: (Start)
%F a(0)=3; for n>0, a(n) = n*a(n-1)-n+1.
%F Let E(x) be the e.g.f., then
%F E(x)=(x*G(0)-2)/(x-1), where G(k)= 1 - 1/(x - x^3/(x^2 - (k+1)/G(k+1)));(continued fraction, 3rd kind, 3-step).
%F E(x)=x*G(0)/(x-1), where G(k)= 1 - 1/(x + 2*x*(x-1)*k!/(1 - 2*(x-1)*k! - x^2/(x^2 + 2*(x-1)*(k+1)!/G(k+1)))); (continued fraction, 3rd kind, 4-step).
%F (End).
%p spec := [S,{S=Union(Sequence(Z),Sequence(Z),Set(Z))},labeled]: seq(combstruct[count](spec,size=n), n=0..20);
%p a[0]:=3: for n from 1 to 21 do a[n]:=n*a[n-1]-n+1; od:
%p seq(a[n], n=0..20). # _Sergei N. Gladkovskii_, Jul 04 2012
%t lst={};s=-3;Do[s+=(n+=s*n);AppendTo[lst, s], {n, 0, 5!}];lst (* _Vladimir Joseph Stephan Orlovsky_, Oct 10 2008 *)
%t FoldList[#1*#2 - #2 + 1 &, 3, Range[19]] (* _Robert G. Wilson v_, Jul 07 2012 *)
%t Table[2 n! + 1, {n, 0, 20}] (* _Vincenzo Librandi_, Sep 29 2013 *)
%o (Magma) [2*Factorial(n) + 1: n in [0..20]]; /* or */ [3] cat [n eq 1 select n+2 else n*Self(n-1)-n+1: n in [1..25] ]; // _Vincenzo Librandi_, Sep 29 2013
%Y Cf. sequences of the type k*n!+1: A038507 (k=1), this sequence, A173324 (k=3), A173322 (k=4), A173319 (k=5), A173314 (k=6).
%K nonn,easy
%O 0,1
%A encyclopedia(AT)pommard.inria.fr, Jan 25 2000
%E Definition replaced with the closed formula by _Bruno Berselli_, Sep 28 2013