login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A052531
If n is even then 2^n+1 otherwise 2^n.
5
2, 2, 5, 8, 17, 32, 65, 128, 257, 512, 1025, 2048, 4097, 8192, 16385, 32768, 65537, 131072, 262145, 524288, 1048577, 2097152, 4194305, 8388608, 16777217, 33554432, 67108865, 134217728, 268435457, 536870912, 1073741825, 2147483648
OFFSET
0,1
LINKS
IBM Research, Control-flow graphs, Ponder This Challenge, October 2020.
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