OFFSET
0,3
LINKS
Harvey P. Dale, Table of n, a(n) for n = 0..999 [Offset adapted by Georg Fischer, Jun 06 2021]
MAPLE
a:= proc(n) option remember;
if n<3 then n
elif n=3 then 1
else a(n-1) - (n-1)*a(n-4)
fi;
end: seq(a(n), n=0..30); # G. C. Greubel, Oct 06 2019
MATHEMATICA
a[0]=0; a[1]=1; a[2]=2; a[3]=1; a[n_]:= a[n]= a[n-1] - (n-1)*a[n-4]; Table[a[n], {n, 0, 30}]
RecurrenceTable[{a[0]==0, a[1]==1, a[2]==2, a[3]==1, a[n]==a[n-1]- (n-1) a[n-4]}, a, {n, 0, 30}] (* Harvey P. Dale, Nov 28 2014 *)
PROG
(PARI) my(m=30, v=concat([0, 1, 2, 1], vector(m-4))); for(n=5, m, v[n] = v[n-1] - (n-2)*v[n-4]); v \\ G. C. Greubel, Oct 06 2019
(Magma) I:=[0, 1, 2, 1]; [n le 4 select I[n] else Self(n-1) - (n-2)*Self(n-4): n in [1..30]]; // G. C. Greubel, Oct 06 2019
(Sage)
@CachedFunction
def a(n):
if (n<3): return n
elif (n==3): return 1
else: return a(n-1) - (n-1)*a(n-4)
[a(n) for n in (0..30)] # G. C. Greubel, Oct 06 2019
(GAP)
a:= function(n)
if n<3 then return n;
elif n=3 then return 1;
else return a(n-1) - (n-1)*a(n-4);
fi;
end;
List([1..30], n-> a(n) ); # G. C. Greubel, Oct 06 2019
CROSSREFS
KEYWORD
sign
AUTHOR
Roger L. Bagula, Sep 12 2006
EXTENSIONS
Edited by N. J. A. Sloane, Sep 12 2006
Offset corrected by Georg Fischer, Jun 06 2021
STATUS
approved