login
A122022
a(n) = a(n-1) - (n-1)*a(n-4), with a(0) = 0, a(1) = 1, a(2) = 2, a(3) = 1.
4
0, 1, 2, 1, 1, -3, -13, -19, -26, -2, 115, 305, 591, 615, -880, -5150, -14015, -23855, -8895, 83805, 350090, 827190, 1013985, -829725, -8881795, -28734355, -54083980, -32511130, 207297335, 1011859275, 2580294695, 3555628595, -2870588790, -35250085590
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