login
a(2*n+1) = 1, a(2*n) = 2*a(2*n-2) - 1.
2

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

%S 2,1,3,1,5,1,9,1,17,1,33,1,65,1,129,1,257,1,513,1,1025,1,2049,1,4097,

%T 1,8193,1,16385,1,32769,1,65537,1,131073,1,262145,1,524289,1,1048577,

%U 1,2097153,1,4194305,1,8388609,1,16777217,1,33554433,1,67108865,1

%N a(2*n+1) = 1, a(2*n) = 2*a(2*n-2) - 1.

%C Interleaving of A000051 and A000012. - _Klaus Brockhaus_, Jun 27 2011

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

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

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

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

%F a(n) = +a(n-1) +2*a(n-2) -2*a(n-3).

%F a(n) = 1 + Sum(1/2*_alpha^(-n), _alpha=RootOf(-1+2*_Z^2)).

%F a(n) = abs(a(n-1)-a(n-2)-a(n-1)*a(n-2)), a(0)=2, a(1)=1. - _Pasi Airikka_, Jun 27 2011

%F a(n) = 1 + (1+(-1)^n)*sqrt(2)^(n-2). - _Bruno Berselli_, Jun 27 2011

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

%t LinearRecurrence[{1,2,-2}, {2,1,3}, 60] (* _G. C. Greubel_, May 07 2019 *)

%o (Magma) [ n eq 1 select 2 else IsOdd(n) select 2*Self(n-2)-1 else 1: n in [1..60] ]; // _Klaus Brockhaus_, Jun 27 2011

%o (Magma) I:=[ 2, 1 ]; [ n le 2 select I[n] else Abs(Self(n-1)-Self(n-2)-Self(n-1)*Self(n-2)): n in [1..60] ]; // _Klaus Brockhaus_, Jun 27 2011

%o (PARI) my(x='x+O('x^60)); Vec((2-x-2*x^2)/((1-2*x^2)*(1-x))) \\ _G. C. Greubel_, May 07 2019

%o (Sage) ((2-x-2*x^2)/((1-2*x^2)*(1-x))).series(x, 60).coefficients(x, sparse=False) # _G. C. Greubel_, May 07 2019

%o (GAP) a:=[2,1,3];; for n in [4..60] do a[n]:=a[n-1]+2*a[n-2]-2*a[n-3]; od; a; # _G. C. Greubel_, May 07 2019

%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