login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A121959 a(n) = (n-3)*a(n-1) + a(n-4), with a(1)=0, a(2)=1, a(3)=2, a(4)=3. 1

%I #15 Sep 08 2022 08:45:27

%S 0,1,2,3,6,19,78,393,2364,16567,132614,1193919,11941554,131373661,

%T 1576616546,20497209017,286972867792,4304724390541,68877166865202,

%U 1170932333917451,21077068983381910,400468615408646831

%N a(n) = (n-3)*a(n-1) + a(n-4), with a(1)=0, a(2)=1, a(3)=2, a(4)=3.

%H G. C. Greubel, <a href="/A121959/b121959.txt">Table of n, a(n) for n = 1..450</a>

%p a:= proc(n) option remember;

%p if n<5 then n-1

%p else (n-3)*a(n-1) + a(n-4)

%p fi;

%p end:

%p seq(a(n), n=1..30); # _G. C. Greubel_, Oct 05 2019

%t (* First program *)

%t M = {{0,1,0,0}, {0,0,1,0}, {0,0,0,1}, {1,0,0,n}}; v[1] = {0,1,2,3};

%t v[n_] := v[n]= M.v[n-1]; Table[Floor[v[n][[1]]], {n,30}]

%t Det[M - x*IdentityMatrix[4]]

%t (* Second program *)

%t 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 *)

%o (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

%o (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

%o (Sage)

%o def a(n):

%o if (n<5): return n-1

%o else: return (n-3)*a(n-1) + a(n-4)

%o [a(n) for n in (1..30)] # _G. C. Greubel_, Oct 05 2019

%o (GAP)

%o a:= function(n)

%o if n<5 then return n-1;

%o else return (n-3)*a(n-1) + a(n-4);

%o fi;

%o end;

%o List([1..30], n-> a(n) ); # _G. C. Greubel_, Oct 05 2019

%K nonn

%O 1,3

%A _Roger L. Bagula_, Sep 02 2006

%E Definition replaced with recurrence by the Assoc. Eds. of the OEIS, Mar 27 2010

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 14 09:30 EDT 2024. Contains 375159 sequences. (Running on oeis4.)