OFFSET
1,3
LINKS
Muniru A Asiru, Table of n, a(n) for n = 1..300
T. Mansour and M. Shattuck, Counting Peaks and Valleys in a Partition of a Set, J. Int. Seq. 13 (2010), 10.6.8, Table 1.
Index entries for linear recurrences with constant coefficients, signature (3,-3,2,-1).
FORMULA
From Colin Barker, Nov 07 2017: (Start)
G.f.: x^2*(1 - x + x^2) / ((1 - x)*(1 - 2*x + x^2 - x^3)).
a(n) = 3*a(n-1) - 3*a(n-2) + 2*a(n-3) - a(n-4) for n>4. (End)
a(n) - a(n-1) = A005251(n). - R. J. Mathar, Mar 11 2021
MAPLE
a := proc(n) option remember: if n = 1 then 0 elif n = 2 then 1 elif n=3 then 2 elif n=4 then 4 elif n >= 5 then 3*procname(n-1) -3*procname(n-2)+2*procname(n-3)-procname(n-4) fi; end:
seq(a(n), n = 0..100); # Muniru A Asiru, Jan 25 2018
MATHEMATICA
LinearRecurrence[{3, -3, 2, -1}, {0, 1, 2, 4}, 40] (* Vincenzo Librandi, Jan 26 2018 *)
PROG
(GAP) a:=[0, 1, 2, 4]; for n in [5..10^2] do a[n]:=3*a[n-1]-3*a[n-2]+2*a[n-3]-a[n-4]; od; a; # Muniru A Asiru, Jan 25 2018
(Magma) I:=[0, 1, 2, 4]; [n le 4 select I[n] else 3*Self(n-1)-3*Self(n-2)+2*Self(n-3)-Self(n-4): n in [1..40]]; // Vincenzo Librandi, Jan 26 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
R. J. Mathar, Jul 09 2017
STATUS
approved