OFFSET
0,1
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
IBM Research, Control-flow graphs, Ponder This Challenge, October 2020.
INRIA Algorithms Project, Encyclopedia of Combinatorial Structures 461
Index entries for linear recurrences with constant coefficients, signature (2,1,-2).
FORMULA
G.f.: (2 - 2*x - x^2)/( (1-x^2)*(1-2*x) ).
a(n) = a(n-1) + 2*a(n-2) - 1, with a(0) = 2, a(1) = 2, a(2) = 5.
a(n) = 2^n + Sum_{alpha = RootOf(-1+x^2)} alpha^(-n)/2.
a(n) = 2*a(n-1) + a(n-2) - 2*a(n-3), with a(0) = 2, a(1) = 2, a(2) = 5. - G. C. Greubel, May 09 2019
a(n) = 2^n + (1 + (-1)^n)/2. - G. C. Greubel, Oct 17 2019
E.g.f.: exp(2*x) + cosh(x). - Stefano Spezia, Oct 18 2019
MAPLE
spec:= [S, {S=Union(Sequence(Union(Z, Z)), Sequence(Prod(Z, Z)))}, unlabeled]: seq(combstruct[count](spec, size=n), n=0..20);
seq(2^n + (1+(-1)^n)/2, n=0..30); # G. C. Greubel, Oct 17 2019
MATHEMATICA
2^# + (1 - Mod[#, 2]) & /@ Range[0, 40] (* Peter Pein, Jan 11 2008 *)
Table[If[EvenQ[n], 2^n + 1, 2^n], {n, 0, 40}] (* Vladimir Joseph Stephan Orlovsky, Feb 07 2010, modified by G. C. Greubel, May 09 2019 *)
Table[2^n + Boole[EvenQ[n]], {n, 0, 31}] (* Alonso del Arte, May 09 2019 *)
PROG
(PARI) my(x='x+O('x^40)); Vec((2-2*x-x^2)/((1-x^2)*(1-2*x))) \\ G. C. Greubel, May 09 2019
(PARI) a(n) = 1<<n + 1 - (n%2) \\ David A. Corneth, Oct 18 2019
(Magma) [2^n + (1+(-1)^n)/2: n in [0..30]]; // G. C. Greubel, May 09 2019
(Sage) [2^n + (1+(-1)^n)/2 for n in (0..30)] # G. C. Greubel, May 09 2019
(GAP) a:=[2, 2, 5];; for n in [4..40] do a[n]:=2*a[n-1]+a[n-2]-2*a[n-3]; od; a; # G. C. Greubel, May 09 2019
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
encyclopedia(AT)pommard.inria.fr, Jan 25 2000
EXTENSIONS
More terms from James A. Sellers, Jun 05 2000
Better definition from Peter Pein (petsie(AT)dordos.net), Jan 11 2008
STATUS
approved