%I #26 Sep 23 2022 16:32:25
%S 1,5,7,15,19,35,43,75,91,155,187,315,379,635,763,1275,1531,2555,3067,
%T 5115,6139,10235,12283,20475,24571,40955,49147,81915,98299,163835,
%U 196603,327675,393211,655355,786427,1310715,1572859,2621435,3145723
%N Sequence of sums of alternating increasing powers of 2.
%C Found as a question on http://mail.python.org/mailman/listinfo/tutor poster: reavey.
%H G. C. Greubel, <a href="/A079360/b079360.txt">Table of n, a(n) for n = 0..5000</a>
%H Tutor User "reavey" (reavey@nep.net) and others, <a href="https://mail.python.org/pipermail/tutor/2003-February/thread.html#20681">How to write an algorithm for sequence</a>, Tutor -- Discussion for learning programming with Python, 2003.
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,2,-2).
%F a(2n) = 6*2^n - 5, a(2n-1) = 5*(2^n - 1). - _Benoit Cloitre_, Feb 16 2003
%F From _Colin Barker_, Sep 19 2012: (Start)
%F a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3).
%F G.f.: (1+4*x)/((1-x)*(1-2*x^2)). (End)
%p seq(coeff(series((1+4*x)/((1-x)*(1-2*x^2)), x, n+1), x, n), n = 0..40); # _G. C. Greubel_, Aug 07 2019
%t LinearRecurrence[{1,2,-2}, {1,5,7}, 40] (* _G. C. Greubel_, Aug 07 2019 *)
%o (PARI) seq(n) = { j=a=1; p=2; print1(1" "); while(j<=n, a = a + 2^p; print1(a" "); a = a+2^(p-1); print1(a" "); p+=1; j+=2; ) }
%o (PARI) a(n)=if(n<0,0,(6-n%2)*2^ceil(n/2)-5)
%o (Magma) I:=[1,5,7]; [n le 3 select I[n] else Self(n-1) +2*Self(n-2) -2*Self(n-3): n in [1..40]]; // _G. C. Greubel_, Aug 07 2019
%o (Sage)
%o @CachedFunction
%o def a(n):
%o if (n==0): return 1
%o elif (1<=n<=2): return nth_prime(n+2)
%o else: return a(n-1) + 2*a(n-2) - 2*a(n-3)
%o [a(n) for n in (0..40)] # _G. C. Greubel_, Aug 07 2019
%o (GAP) a:=[1,5,7];; for n in [4..30] do a[n]:=a[n-1]+2*a[n-2]-2*a[n-3]; od; a; # _G. C. Greubel_, Aug 07 2019
%Y Cf. A079361, A079362, A048488 (bisection).
%K easy,nonn
%O 0,2
%A _Cino Hilliard_, Feb 15 2003