OFFSET
0,3
MAPLE
a:= proc(n) if n<2 then 1 else a(n) := -(2*n-1)*a(n-1) + a(n-2) fi end:
seq (a(n), n=0..25); # Sergei N. Gladkovskii, Jul 04 2012
MATHEMATICA
k = 2; b[0] = 1; b[n_] := b[n] = b[n - 1] + k
M[0] := {{-b[n], -1}, {1, 0}};
M[1] := {{-b[n], 1}, {-1, 0}};
v[0] = {1, 1};
v[n_] := v[n] = M[Mod[n, 2]].v[n - 1];
Table[v[n][[1]], {n, 1, 30}]
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 *)
PROG
(PARI)
a(n)= if ( n<=1, 1, -(2*n-1)*a(n-1) + a(n-2) );
/* note this is inefficient, optimize using memoization: */
v=vector(66); v[1]=1; v[2]=1; /* PARI's vectors are one-based */
for (n=3, #v, v[n] = -(2*n-3)*v[n-1] + v[n-2]);
v /* show terms */
/* Joerg Arndt, Jul 023 2012 */
CROSSREFS
KEYWORD
sign
AUTHOR
Roger L. Bagula and Gary W. Adamson, Sep 27 2008
STATUS
approved