OFFSET
1,3
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..450
MAPLE
a:= proc(n) option remember;
if n<5 then n-1
else (n-3)*a(n-1) + a(n-4)
fi;
end:
seq(a(n), n=1..30); # G. C. Greubel, Oct 05 2019
MATHEMATICA
(* First program *)
M = {{0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {1, 0, 0, n}}; v[1] = {0, 1, 2, 3};
v[n_] := v[n]= M.v[n-1]; Table[Floor[v[n][[1]]], {n, 30}]
Det[M - x*IdentityMatrix[4]]
(* Second program *)
a[n_]:= a[n] = If[n<5, n-1, (n-3)*a[n-1] + a[n-4]]; Table[a[n], {n, 30}] (* G. C. Greubel, Oct 05 2019 *)
PROG
(PARI) my(m=30, v=concat([0, 1, 2, 3], vector(m-4))); for(n=5, m, v[n]=(n-3)*v[n-1] +v[n-4]); v \\ G. C. Greubel, Oct 05 2019
(Magma) I:=[0, 1, 2, 3]; [n le 4 select I[n] else (n-3)*Self(n-1) + Self(n-4): n in [1..30]]; // G. C. Greubel, Oct 05 2019
(Sage)
def a(n):
if (n<5): return n-1
else: return (n-3)*a(n-1) + a(n-4)
[a(n) for n in (1..30)] # G. C. Greubel, Oct 05 2019
(GAP)
a:= function(n)
if n<5 then return n-1;
else return (n-3)*a(n-1) + a(n-4);
fi;
end;
List([1..30], n-> a(n) ); # G. C. Greubel, Oct 05 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Roger L. Bagula, Sep 02 2006
EXTENSIONS
Definition replaced with recurrence by the Assoc. Eds. of the OEIS, Mar 27 2010
STATUS
approved