login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A052531 If n is even then 2^n+1 otherwise 2^n. 5

%I #56 Sep 08 2022 08:44:59

%S 2,2,5,8,17,32,65,128,257,512,1025,2048,4097,8192,16385,32768,65537,

%T 131072,262145,524288,1048577,2097152,4194305,8388608,16777217,

%U 33554432,67108865,134217728,268435457,536870912,1073741825,2147483648

%N If n is even then 2^n+1 otherwise 2^n.

%H G. C. Greubel, <a href="/A052531/b052531.txt">Table of n, a(n) for n = 0..1000</a>

%H IBM Research, <a href="https://www.research.ibm.com/haifa/ponderthis/challenges/October2020.html">Control-flow graphs</a>, Ponder This Challenge, October 2020.

%H INRIA Algorithms Project, <a href="http://ecs.inria.fr/services/structure?nbr=461">Encyclopedia of Combinatorial Structures 461</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (2,1,-2).

%F G.f.: (2 - 2*x - x^2)/( (1-x^2)*(1-2*x) ).

%F a(n) = a(n-1) + 2*a(n-2) - 1, with a(0) = 2, a(1) = 2, a(2) = 5.

%F a(n) = 2^n + Sum_{alpha = RootOf(-1+x^2)} alpha^(-n)/2.

%F 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

%F a(n) = 2^n + (1 + (-1)^n)/2. - _G. C. Greubel_, Oct 17 2019

%F E.g.f.: exp(2*x) + cosh(x). - _Stefano Spezia_, Oct 18 2019

%p spec:= [S,{S=Union(Sequence(Union(Z,Z)),Sequence(Prod(Z,Z)))},unlabeled]: seq(combstruct[count](spec,size=n), n=0..20);

%p seq(2^n + (1+(-1)^n)/2, n=0..30); # _G. C. Greubel_, Oct 17 2019

%t 2^# + (1 - Mod[#, 2]) & /@ Range[0, 40] (* Peter Pein, Jan 11 2008 *)

%t 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 *)

%t Table[2^n + Boole[EvenQ[n]], {n, 0, 31}] (* _Alonso del Arte_, May 09 2019 *)

%o (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

%o (PARI) a(n) = 1<<n + 1 - (n%2) \\ _David A. Corneth_, Oct 18 2019

%o (Magma) [2^n + (1+(-1)^n)/2: n in [0..30]]; // _G. C. Greubel_, May 09 2019

%o (Sage) [2^n + (1+(-1)^n)/2 for n in (0..30)] # _G. C. Greubel_, May 09 2019

%o (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

%Y Cf. A001045, A042950, A052929, A062510, A087288, A280345.

%K easy,nonn

%O 0,1

%A encyclopedia(AT)pommard.inria.fr, Jan 25 2000

%E More terms from _James A. Sellers_, Jun 05 2000

%E Better definition from Peter Pein (petsie(AT)dordos.net), Jan 11 2008

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 18:12 EDT 2024. Contains 371750 sequences. (Running on oeis4.)