This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A209398 #36 May 22 2025 10:21:35 %S A209398 0,0,0,2,7,17,39,88,192,408,855,1775,3655,7478,15228,30898,62511, %T A209398 126177,254223,511472,1027840,2063600,4140015,8300767,16635087, %U A209398 33324462,66736764,133615658,267461287,535294673,1071191415,2143357000,4288290240,8579130888 %N A209398 Number of subsets of {1,...,n} containing two elements whose difference is 2. %C A209398 Also, the number of bitstrings of length n containing either 101 or 111. %H A209398 David Nacin, <a href="/A209398/b209398.txt">Table of n, a(n) for n = 0..500</a> %H A209398 <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (3,-2,1,-1,-2). %F A209398 a(n) = 3*a(n-1) - 2*a(n-2) + a(n-3) - a(n-4) - 2*a(n-5), a(0)=0, a(1)=0, a(2)=0, a(3)=2, a(4)=7. %F A209398 a(n) = 2^n - F(2+floor(n/2))*F(floor(2+(n+1)/2)), where F(n) are the Fibonacci numbers. %F A209398 a(n) = 2^n - A006498(n+2). %F A209398 G.f.: (2*x^3 + 1*x^4)/(1 - 3*x + 2*x^2 - x^3 + x^4 + 2*x^5) = x^3*(2 + x) / ((1 - 2*x)*(1 + x^2)*(1 - x - x^2)). %F A209398 E.g.f.: (2*cos(x) + 5*cosh(2*x) + sin(x) + 5*sinh(2*x) - exp(x/2)*(7*cosh(sqrt(5)*x/2) + 3*sqrt(5)*sinh(sqrt(5)*x/2)))/5. - _Stefano Spezia_, Mar 12 2024 %e A209398 For n=3 the subsets containing 1 and 3 are {1,3} and {1,2,3} so a(3)=2. %t A209398 Table[2^n -Fibonacci[Floor[n/2] + 2]*Fibonacci[Floor[(n + 1)/2] + 2], {n, 0,30}] %t A209398 LinearRecurrence[{3, -2, 1, -1, -2}, {0, 0, 0, 2, 7}, 40] %t A209398 CoefficientList[ Series[x^3 (x +2)/(2x^5 +x^4 -x^3 +2x^2 -3x +1), {x, 0, 33}], x] (* _Robert G. Wilson v_, Jan 03 2018 *) %t A209398 a[n_] := Floor[ N[(2^-n ((50 - 14 Sqrt[5]) (1 - Sqrt[5])^n + ((-1 + 2I) (-2I)^n - (1 + 2I) (2I)^n + 5 4^n) (15 + 11 Sqrt[5]) - 2 (1 + Sqrt[5])^n (85 + 37 Sqrt[5])))/(150 + 110 Sqrt[5])]]; Array[a, 33] (* _Robert G. Wilson v_, Jan 03 2018 *) %o A209398 (Python) %o A209398 #Through Recurrence %o A209398 def a(n, adict={0:0, 1:0, 2:0, 3:2, 4:7}): %o A209398 if n in adict: %o A209398 return adict[n] %o A209398 adict[n]=3*a(n-1)-2*a(n-2)+a(n-3)-a(n-4)-2*a(n-5) %o A209398 return adict[n] %o A209398 (Python) %o A209398 #Returns the actual list of valid subsets %o A209398 def contains101(n): %o A209398 patterns=list() %o A209398 for start in range (1,n-1): %o A209398 s=set() %o A209398 for i in range(3): %o A209398 if (1,0,1)[i]: %o A209398 s.add(start+i) %o A209398 patterns.append(s) %o A209398 s=list() %o A209398 for i in range(2,n+1): %o A209398 for temptuple in comb(range(1,n+1),i): %o A209398 tempset=set(temptuple) %o A209398 for sub in patterns: %o A209398 if sub <= tempset: %o A209398 s.append(tempset) %o A209398 break %o A209398 return s %o A209398 #Counts all such subsets using the preceding function %o A209398 def countcontains101(n): %o A209398 return len(contains101(n)) %o A209398 (PARI) x='x+O('x^30); concat([0,0,0], Vec(x^3*(2+x)/((1-2*x)*(1+x^2)*(1-x-x^2)))) \\ _G. C. Greubel_, Jan 03 2018 %o A209398 (Magma) [2^n - Fibonacci(Floor(n/2) + 2)*Fibonacci(Floor((n + 1)/2) + 2): n in [0..30]]; // _G. C. Greubel_, Jan 03 2018 %Y A209398 Cf. A006498, A209399, A209400. %K A209398 nonn,easy %O A209398 0,4 %A A209398 _David Nacin_, Mar 07 2012