A094024 Alternating 1 with one less than the powers of 2.
1, 1, 1, 3, 1, 7, 1, 15, 1, 31, 1, 63, 1, 127, 1, 255, 1, 511, 1, 1023, 1, 2047, 1, 4095, 1, 8191, 1, 16383, 1, 32767, 1, 65535, 1, 131071, 1, 262143, 1, 524287, 1, 1048575, 1, 2097151, 1, 4194303, 1, 8388607, 1, 16777215, 1, 33554431, 1, 67108863, 1
Offset: 0
Links
- Vincenzo Librandi, Table of n, a(n) for n = 0..5000
- Index entries for linear recurrences with constant coefficients, signature (-1,2,2).
Programs
-
Magma
[Ceiling((-1)^n+((Sqrt(2))^n-(-Sqrt(2))^n)/Sqrt(2)): n in [0..50]]; // Vincenzo Librandi, Aug 17 2011
-
Mathematica
LinearRecurrence[{-1, 2, 2}, {1, 1, 1}, 60] (* Jean-François Alcover, Jul 02 2018 *)
-
PARI
a(n)=(1-(-1)^n)*2^floor(n/2)+(-1)^n
Formula
G.f.: (1+2*x) / ((1+x) * (1-2*x^2)).
E.g.f.: exp(-x) + 2*sinh(sqrt(2)*x) / sqrt(2).
a(n) = (-1)^n + ((sqrt(2))^n - (-sqrt(2))^n) / sqrt(2).
a(n) = (1-(-1)^n) * 2^floor(n/2) + (-1)^n. - Ralf Stephan, Aug 19 2013
a(n) = -a(n-1) + 2*a(n-2) + 2*a(n-3). - Andrew Howroyd, Feb 21 2018
Extensions
Better name from Ralf Stephan, Aug 19 2013
Even terms for n >= 60 corrected in b-file by Andrew Howroyd, Feb 21 2018
Comments