%I #68 Jan 31 2024 09:47:42
%S 0,1,3,13,68,421,3015,24541,223884,2263381,25121075,303716281,
%T 3973432728,55931774473,842950049823,13543132571641,231076203767720,
%U 4172914800390601,79516457411189139,1594502063024173381,33564059780918830140,740003817243238436461,17053651856375402868743
%N a(n) = (n+1)*a(n-1) + a(n-2), with a(0)=0, a(1)=1.
%C Numerator of convergent to BesselI(0,2)/BesselI(1,2) for which the continued fraction expansion is [1,2,3....,n]. - _Benoit Cloitre_, Mar 27 2003
%C Numerator of continued fraction C(n) minus denominator of continued fraction C(n), where C(n) = [ 1; 2,3,4,...n ]. - _Melvin Peralta_, Jan 17 2017
%H G. C. Greubel, <a href="/A058307/b058307.txt">Table of n, a(n) for n = 0..445</a> (terms n=0..100 from T. D. Noe)
%H Olivier Bodini, Antoine Genitrini, Cécile Mailler, and Mehdi Naima, <a href="https://hal.archives-ouvertes.fr/hal-02865198">Strict monotonic trees arising from evolutionary processes: combinatorial and probabilistic study</a>, hal-02865198 [math.CO] / [math.PR] / [cs.DS] / [cs.DM], 2020.
%H C. Cannings, <a href="http://dx.doi.org/10.4236/am.2013.45105">The Stationary Distributions of a Class of Markov Chains</a>, Applied Mathematics, Vol. 4 No. 5, 2013, pp. 769-773.
%H S. Janson, <a href="https://doi.org/10.46298/dmtcs.520">A divergent generating function that can be summed and analysed analytically</a>, Discrete Mathematics and Theoretical Computer Science; 2010, Vol. 12, No. 2, 1-22.
%H Russell Walsmith, <a href="/A058307/a058307.pdf">Cl-Chemy II</a>
%F From _Wouter Meeussen_, Feb 02 2001: (Start)
%F a(2*r+1) = Sum_{j=0..r} (binomial(r+j, r-j)*(r+j)!/(r-j)! - binomial(r + j, r-j-1)*(r+j+1)!/(r-j)!) and
%F a(2*r) = Sum_{j=0..r} (binomial(r+j+1, r-j)*(r+j+1)!/(r-j)! - binomial(r +j, r-j)*(r+j+1)!/(r-j+1)! + binomial(r+j+1, r-j)*(r+j+1)!/(r-j)!). (End)
%F E.g.f.: Pi*(BesselI(2, 2)*BesselY(2, 2*I*sqrt(1-x)) - BesselY(2,2*I)*BesselI(2, 2*sqrt(1-x)))/(1-x). Motivated to look into e.g.f.'s for such recurrences by email exchange with Gary Detlefs. One has to use simplifications after differentiation and putting x=0. See Abramowitz-Stegun handbook p. 360, 9.1.16. - _Wolfdieter Lang_, May 18 2010
%F Limit n->infinity a(n)/(n+1)! = BesselI(0,2)-BesselI(1,2) = 0.688948447698738204... - _Vaclav Kotesovec_, Jan 05 2013
%F a(n) = Sum_{k = 0..floor((n-1)/2)} (n-2*k-1)!*binomial(n-k-1,k)* binomial(n-k+1,k+2). Cf. A058798. - _Peter Bala_, Aug 01 2013
%F a(n) = (n+1)!*hypergeometric([1/2-n/2,1-n/2],[3,-1-n,1-n],4)/2 for n >= 2. - _Peter Luschny_, Sep 10 2014
%F E.g.f.: 2*(I(2,2)*K(2, 2*sqrt(1-x)) - K(2,2)*I(2, 2*sqrt(1-x)))/(1-x), where I(n, x) and K(n, x) are the modified Bessel functions of the second kind. - _G. C. Greubel_, Oct 07 2019
%p A058307 := proc(n) option remember; if n <= 1 then n else A058307(n-2)+(n+1)*A058307(n-1); fi; end;
%p a:= proc(n) option remember;
%p if n<2 then n
%p else (n+1)*a(n-1) + a(n-2)
%p fi;
%p end:
%p seq(a(n), n=0..30); # _G. C. Greubel_, Oct 07 2019
%t RecurrenceTable[{a[0]==0, a[1]==1, a[n]==(n+1)*a[n-1]+a[n-2]}, a, {n, 0, 30}] (* _Vincenzo Librandi_, May 06 2013 *)
%t Table[FullSimplify[(-BesselI[2+n,-2] * BesselK[2,2] + BesselI[2,2] * BesselK[2+n,2]) / (BesselI[3,2] * BesselK[2,2] + BesselI[2,2] * BesselK[3,2])],{n,0,20}] (* _Vaclav Kotesovec_, Feb 14 2014 *)
%t a[n_]:= a[n]= If[n<2, n, (n+1)*a[n-1] +a[n-2]]; Table[a[n], {n,0,30}] (* _G. C. Greubel_, Oct 07 2019 *)
%o (Magma) [n le 2 select n-1 else Self(n-2)+Self(n-1)*(n): n in [1..30]]; // _Vincenzo Librandi_, May 06 2013
%o (Sage)
%o def A058307(n):
%o if n < 2: return n
%o return factorial(n+1)*hypergeometric([1/2-n/2,1-n/2], [3,-1-n,1-n], 4)/2
%o [round(A058307(n).n(100)) for n in (0..21)] # _Peter Luschny_, Sep 10 2014
%o (PARI) my(m=30, v=concat([0,1], vector(m-2))); for(n=3, m, v[n]=n*v[n-1] +v[n-2]); v \\ _G. C. Greubel_, Nov 24 2018
%o (Sage)
%o @CachedFunction
%o def a(n):
%o if (n<2): return n
%o else: return (n+1)*a(n-1) + a(n-2)
%o [a(n) for n in (0..30)] # _G. C. Greubel_, Nov 24 2018
%o (GAP)
%o a:= function(n)
%o if n<2 then return n;
%o else return (n+1)*a(n-1) + a(n-2);
%o fi;
%o end;
%o List([0..30], n-> a(n) ); # _G. C. Greubel_, Oct 07 2019
%Y A column of A058294. Except for first term, -1 times row sums of A053495.
%Y Cf. A001053, A060997, A058798.
%K nonn
%O 0,3
%A _N. J. A. Sloane_, Dec 09 2000