OFFSET
0,3
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,0,0,1,-1).
FORMULA
From Bruno Berselli, Jan 27 2011: (Start)
G.f.: x*(1+x+2*x^2)/((1+x)*(1+x^2)*(1-x)^2).
a(n) = a(n-1) + a(n-4) - a(n-5) for n>4.
a(n) = n + A121262(n+1). (End)
a(n) = n when n+1 is not a multiple of 4, and a(n) = n+1 when n+1 is a multiple of 4. - Dennis P. Walsh, Aug 06 2012
a(n) = (4*n+1-i^(2*n)+(-i)^(1+n)+i^(1+n))/4 where i=sqrt(-1). - Wesley Ivan Hurt, Jun 04 2016
a(n) = n+1-(sign((n+1) mod 4) mod 3). - Wesley Ivan Hurt, Sep 26 2017
MAPLE
A140201:=n->(4*n+1-I^(2*n)+(-I)^(1+n)+I^(1+n))/4: seq(A140201(n), n=0..100); # Wesley Ivan Hurt, Jun 04 2016
MATHEMATICA
Accumulate[PadRight[{}, 68, {0, 1, 1, 2}]] (* Harvey P. Dale, Aug 19 2011 *)
PROG
(Magma) I:=[0, 1, 2, 4, 4]; [n le 5 select I[n] else Self(n-1)+Self(n-4)-Self(n-5): n in [1..80]]; // Vincenzo Librandi, Sep 17 2012
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Nadia Heninger and N. J. A. Sloane, Jun 09 2008
STATUS
approved