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!)
A079360 Sequence of sums of alternating increasing powers of 2. 4
1, 5, 7, 15, 19, 35, 43, 75, 91, 155, 187, 315, 379, 635, 763, 1275, 1531, 2555, 3067, 5115, 6139, 10235, 12283, 20475, 24571, 40955, 49147, 81915, 98299, 163835, 196603, 327675, 393211, 655355, 786427, 1310715, 1572859, 2621435, 3145723 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
Found as a question on http://mail.python.org/mailman/listinfo/tutor poster: reavey.
LINKS
Tutor User "reavey" (reavey@nep.net) and others, How to write an algorithm for sequence, Tutor -- Discussion for learning programming with Python, 2003.
FORMULA
a(2n) = 6*2^n - 5, a(2n-1) = 5*(2^n - 1). - Benoit Cloitre, Feb 16 2003
From Colin Barker, Sep 19 2012: (Start)
a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3).
G.f.: (1+4*x)/((1-x)*(1-2*x^2)). (End)
MAPLE
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
MATHEMATICA
LinearRecurrence[{1, 2, -2}, {1, 5, 7}, 40] (* G. C. Greubel, Aug 07 2019 *)
PROG
(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; ) }
(PARI) a(n)=if(n<0, 0, (6-n%2)*2^ceil(n/2)-5)
(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
(Sage)
@CachedFunction
def a(n):
if (n==0): return 1
elif (1<=n<=2): return nth_prime(n+2)
else: return a(n-1) + 2*a(n-2) - 2*a(n-3)
[a(n) for n in (0..40)] # G. C. Greubel, Aug 07 2019
(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
CROSSREFS
Cf. A079361, A079362, A048488 (bisection).
Sequence in context: A309292 A050851 A058918 * A314365 A314366 A068580
KEYWORD
easy,nonn
AUTHOR
Cino Hilliard, Feb 15 2003
STATUS
approved

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 24 07:17 EDT 2024. Contains 371920 sequences. (Running on oeis4.)