A052531 If n is even then 2^n+1 otherwise 2^n.
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
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).
Programs
-
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
-
Magma
[2^n + (1+(-1)^n)/2: n in [0..30]]; // G. C. Greubel, May 09 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 *)
-
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<
David A. Corneth, Oct 18 2019 -
Sage
[2^n + (1+(-1)^n)/2 for n in (0..30)] # G. C. Greubel, May 09 2019
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
Extensions
More terms from James Sellers, Jun 05 2000
Better definition from Peter Pein (petsie(AT)dordos.net), Jan 11 2008