OFFSET
1,1
COMMENTS
Previous name was: a(1)=2 then if n even a(n)=a(n-1)+2 and if n odd a(n)=a(n-2)+a(n-1)-1.
This sequence a(n)=A016116(n-1)+A086341(n). Generalization: starting with a(1) even then if n even a(n)=a(n-1)+2 and if n odd a(n)=a(n-2)+a(n-1)-1 you get a new sequence as a(1) increases. But if a(1) is odd, you get always the same sequence with only less values as a(1) increases. If a(1) is even, the sequence difference between two sequences with different but consecutive a(1) is the sequence of powers of 2 = 2,2,4,4,8,8,16,16,32,32,......
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (-1,2,2).
FORMULA
From R. J. Mathar, Nov 13 2009: (Start)
a(n) = -a(n-1) + 2*a(n-2) + 2*a(n-3).
G.f.: x*(2+6*x+5*x^2)/((1+x)*(1-2*x^2)). (End)
EXAMPLE
Starting with a(1)=4 the new sequence is 4,6,9,11,19,21,39,41,79,81,159,161
The sequence difference between sequence starting with a(1)=4 and the sequence starting with a(1)=2 is 2,2,4,4,8,8,16,16,32,32,64,64,.......
MATHEMATICA
LinearRecurrence[{-1, 2, 2}, {2, 4, 5}, 40] (* Harvey P. Dale, Aug 10 2011 *)
Table[3*2^(Floor[(n - 1)/2]) + (-1)^n, {n, 1, 50}] (* G. C. Greubel, Apr 18 2017 *)
PROG
(PARI) a(n)=3*2^floor((n-1)/2)+(-1)^n
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierre CAMI, Sep 20 2004
EXTENSIONS
Equation in the comment corrected by R. J. Mathar, Nov 13 2009
Better name from Ralf Stephan, Aug 19 2013
STATUS
approved