OFFSET
0,5
FORMULA
EXAMPLE
a(4)=2 because we have 4132 and 4231 (the other C(4)=14 simsun permutations of {1,2,3,4} have no 321 patterns at all).
MAPLE
f := sec(x)+tan(x): fser := series(f, x = 0, 52): E := proc (n) options operator, arrow: factorial(n)*coeff(fser, x, n) end proc: C := proc (n) options operator, arrow: binomial(2*n, n)/(n+1) end proc: seq(E(n+1)-C(n), n = 0 .. 23);
MATHEMATICA
A000111[n_] := If[EvenQ[n], Abs[EulerE[n]], Abs[(2^(n+1)*(2^(n+1)-1)* BernoulliB[n+1])/(n+1)]];
a[n_] := A000111[n+1] - CatalanNumber[n];
Table[a[n], {n, 0, 22}] (* Jean-François Alcover, Aug 12 2024 *)
PROG
(Python)
from itertools import count, islice, accumulate
def A166298_gen(): # generator of terms
yield 0
blist, c = (0, 1), 1
for n in count(1):
yield (blist := tuple(accumulate(reversed(blist), initial=0)))[-1] - c
c = c*(4*n+2)//(n+2)
CROSSREFS
KEYWORD
nonn
AUTHOR
Emeric Deutsch, Oct 29 2009
STATUS
approved