login
a(0)=a(1)=1 and a(n) = -(2*n-1)*a(n-1) + a(n-2) for n>=2.
0

%I #18 May 08 2019 14:57:49

%S 1,1,-2,11,-79,722,-8021,104995,-1582946,27015077,-514869409,

%T 10839272666,-249818140727,6256292790841,-169169723493434,

%U 4912178274100427,-152446696220606671,5035653153554120570,-176400307070614826621,6531847014766302705547

%N a(0)=a(1)=1 and a(n) = -(2*n-1)*a(n-1) + a(n-2) for n>=2.

%p a:= proc(n) if n<2 then 1 else a(n) := -(2*n-1)*a(n-1) + a(n-2) fi end:

%p seq (a(n), n=0..25); # _Sergei N. Gladkovskii_, Jul 04 2012

%t k = 2; b[0] = 1; b[n_] := b[n] = b[n - 1] + k

%t M[0] := {{-b[n], -1}, {1, 0}};

%t M[1] := {{-b[n], 1}, {-1, 0}};

%t v[0] = {1, 1};

%t v[n_] := v[n] = M[Mod[n, 2]].v[n - 1];

%t Table[v[n][[1]], {n, 1, 30}]

%t RecurrenceTable[{a[0]==a[1]==1,a[n]==-(2n-1)a[n-1]+a[n-2]},a,{n,20}] (* _Harvey P. Dale_, May 08 2019 *)

%o (PARI)

%o a(n)= if ( n<=1, 1, -(2*n-1)*a(n-1) + a(n-2) );

%o /* note this is inefficient, optimize using memoization: */

%o v=vector(66); v[1]=1; v[2]=1; /* PARI's vectors are one-based */

%o for (n=3,#v, v[n] = -(2*n-3)*v[n-1] + v[n-2]);

%o v /* show terms */

%o /* _Joerg Arndt_, Jul 023 2012 */

%K sign

%O 0,3

%A _Roger L. Bagula_ and _Gary W. Adamson_, Sep 27 2008