OFFSET
0,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (2,-1,2,-1).
FORMULA
G.f.: (1 +x^2)/(1 -2*x +x^2 -2*x^3 +x^4).
a(n) = 2*a(n-1) - a(n-2) + 2*a(n-3) - a(n-4) for n>=4.
EXAMPLE
a(5) = 28 because among the 32 (=2^5) binary sequences of length 5 only 01010, 01011, 00101 and 10101 contain the subsequence 0101.
MAPLE
a[0]:=1:a[1]:=2:a[2]:=4:a[3]:=8: for n from 4 to 35 do a[n]:=2*a[n-1]-a[n-2]+2*a[n-3]-a[n-4] od: seq(a[n], n=0..35);
MATHEMATICA
CoefficientList[Series[(1+x^2)/(1-2x+x^2-2x^3+x^4), {x, 0, 40}], x] (* Geoffrey Critzer, Nov 28 2013 *)
PROG
(Magma) [n le 4 select 2^(n-1) else 2*Self(n-1) -Self(n-2) +2*Self(n-3) -Self(n-4): n in [1..41]]; // G. C. Greubel, Jan 14 2022
(Sage)
@CachedFunction
def A112575(n): return sum((-1)^k*binomial(n-k, k)*lucas_number1(n-2*k, 2, -1) for k in (0..(n/2)))
[A118870(n) for n in (0..40)] # G. C. Greubel, Jan 14 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Emeric Deutsch, May 03 2006
STATUS
approved