OFFSET
1,2
LINKS
Index entries for linear recurrences with constant coefficients, signature (2,-2,2,-1).
FORMULA
From Wesley Ivan Hurt, Jun 04 2016: (Start)
G.f.: x*(1+2*x^2+x^3)/(x-1)^2*(1+x^2).
a(n) = 2*a(n-1) - 2*a(n-2) + 2*a(n-3) - a(n-4) for n>4.
a(n) = (1+i)*(n*(4-4*i)+3*i-3+i^(-n)-i^(1+n))/4 where i=sqrt(-1).
E.g.f.: (2 + sin(x) + cos(x) + (4*x - 3)*exp(x))/2. - Ilya Gutkovskiy, Jun 04 2016
Sum_{n>=1} (-1)^(n+1)/a(n) = (2*sqrt(2)+1)*Pi/16 - log(2)/8. - Amiram Eldar, Dec 24 2021
MAPLE
A047541:=n->(1+I)*(n*(4-4*I)+3*I-3+I^(-n)-I^(1+n))/4: seq(A047541(n), n=1..100); # Wesley Ivan Hurt, Jun 04 2016
MATHEMATICA
Table[(1+I)*(n*(4-4*I)+3*I-3+I^(-n)-I^(1+n))/4, {n, 80}] (* Wesley Ivan Hurt, Jun 04 2016 *)
Select[Range[200], MemberQ[{1, 2, 4, 7}, Mod[#, 8]]&] (* or *) LinearRecurrence[ {2, -2, 2, -1}, {1, 2, 4, 7}, 70] (* Harvey P. Dale, Jul 09 2020 *)
PROG
(PARI) a(n)=n\4*8+[-1, 1, 2, 4][n%4+1] \\ Charles R Greathouse IV, Nov 04 2011
(Magma) [n : n in [0..150] | n mod 8 in [1, 2, 4, 7]]; // Wesley Ivan Hurt, Jun 04 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved