A112387 a(n) = 2^(n/2) if n is even and a(n-1) - a(n-2) if n is odd, a(1) = 1.
1, 1, 2, 1, 4, 3, 8, 5, 16, 11, 32, 21, 64, 43, 128, 85, 256, 171, 512, 341, 1024, 683, 2048, 1365, 4096, 2731, 8192, 5461, 16384, 10923, 32768, 21845, 65536, 43691, 131072, 87381, 262144, 174763, 524288, 349525, 1048576, 699051, 2097152, 1398101, 4194304
Offset: 0
Links
- Harvey P. Dale, Table of n, a(n) for n = 0..1000
- Index entries for linear recurrences with constant coefficients, signature (0,1,0,2).
Programs
-
Maple
a:= proc(n) option remember; `if`(n::even, 2^(n/2), a(n-1)-a(n-2)) end: a(1):=1: seq(a(n), n=0..50); # Alois P. Heinz, Sep 27 2023
-
Mathematica
a[1] = 1; a[2] = 2; a[n_] := a[n] = If[ EvenQ[n], 2^(n/2), a[n - 1] - a[n - 2]]; Array[a, 43] (* Robert G. Wilson v, Dec 05 2005 *) nxt[{n_,a_,b_}]:={n+1,b,If[OddQ[n],2^((n+1)/2),b-a]}; NestList[nxt,{2,1,2},50][[All,2]] (* Harvey P. Dale, Jul 08 2019 *)
Formula
a(n) = 2^(n/2) if n is even, a(n) = a(n-1) - a(n-2) if n is odd, and a(1) = 1.
G.f.: (1+x+x^2)/((1+x^2)*(1-2*x^2)). - Joerg Arndt, Apr 25 2021
a(n) = A135318(n + (-1)^n). - Paul Curtz, Sep 27 2023
E.g.f.: (3*cosh(sqrt(2)*x) + sin(x) + sqrt(2)*sinh(sqrt(2)*x))/3. - Stefano Spezia, Jun 30 2024
Extensions
Edited and extended by Robert G. Wilson v, Dec 05 2005
a(0)=1 prepended by Alois P. Heinz, Sep 27 2023
Comments