A085615 Duplicate of A054726.
1, 1, 2, 8, 48, 352, 2880, 25216, 231168, 2190848, 21292032, 211044352
Offset: 1
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.
G.f.: 1 + x + 2*x^2 + 4*x^3 + 9*x^4 + 21*x^5 + 51*x^6 + 127*x^7 + 323*x^8 + ... . The 21 Motzkin-paths of length 5: UUDDF, UUDFD, UUFDD, UDUDF, UDUFD, UDFUD, UDFFF, UFUDD, UFDUD, UFDFF, UFFDF, UFFFD, FUUDD, FUDUD, FUDFF, FUFDF, FUFFD, FFUDF, FFUFD, FFFUD, FFFFF.
a001006 n = a001006_list !! n a001006_list = zipWith (+) a005043_list $ tail a005043_list -- Reinhard Zumkeller, Jan 31 2012
# Three different Maple scripts for this sequence: A001006 := proc(n) add(binomial(n,2*k)*A000108(k),k=0..floor(n/2)) ; end proc: A001006 := proc(n) option remember; local k; if n <= 1 then 1 else procname(n-1) + add(procname(k)*procname(n-k-2),k=0..n-2); end if; end proc: # n -> [a(0),a(1),..,a(n)] A001006_list := proc(n) local w, m, j, i; w := proc(i,j,n) option remember; if min(i,j,n) < 0 or max(i,j) > n then 0 elif n = 0 then if i = 0 and j = 0 then 1 else 0 fi else w(i, j + 1, n - 1) + w(i - 1, j, n - 1) + w(i + 1, j - 1, n - 1) fi end: [seq( add( add( w(i, j, m), i = 0..m), j = 0..m), m = 0..n)] end: A001006_list(29); # Peter Luschny, May 21 2011
a[0] = 1; a[n_Integer] := a[n] = a[n - 1] + Sum[a[k] * a[n - 2 - k], {k, 0, n - 2}]; Array[a, 30] (* Second program: *) CoefficientList[Series[(1 - x - (1 - 2x - 3x^2)^(1/2))/(2x^2), {x, 0, 29}], x] (* Jean-François Alcover, Nov 29 2011 *) Table[Hypergeometric2F1[(1-n)/2, -n/2, 2, 4], {n,0,29}] (* Peter Luschny, May 15 2016 *) Table[GegenbauerC[n,-n-1,-1/2]/(n+1),{n,0,100}] (* Emanuele Munarini, Oct 20 2016 *) MotzkinNumber = DifferenceRoot[Function[{y, n}, {(-3n-3)*y[n] + (-2n-5)*y[n+1] + (n+4)*y[n+2] == 0, y[0] == 1, y[1] == 1}]]; Table[MotzkinNumber[n], {n, 0, 29}] (* Jean-François Alcover, Oct 27 2021 *)
a[0]:1$ a[1]:1$ a[n]:=((2*n+1)*a[n-1]+(3*n-3)*a[n-2])/(n+2)$ makelist(a[n],n,0,12); /* Emanuele Munarini, Mar 02 2011 */
M(n) := coeff(expand((1+x+x^2)^(n+1)),x^n)/(n+1); makelist(M(n),n,0,60); /* Emanuele Munarini, Apr 04 2012 */
makelist(ultraspherical(n,-n-1,-1/2)/(n+1),n,0,12); /* Emanuele Munarini, Oct 20 2016 */
{a(n) = polcoeff( ( 1 - x - sqrt((1 - x)^2 - 4 * x^2 + x^3 * O(x^n))) / (2 * x^2), n)}; /* Michael Somos, Sep 25 2003 */
{a(n) = if( n<0, 0, n++; polcoeff( serreverse( x / (1 + x + x^2) + x * O(x^n)), n))}; /* Michael Somos, Sep 25 2003 */
{a(n) = if( n<0, 0, n! * polcoeff( exp(x + x * O(x^n)) * besseli(1, 2 * x + x * O(x^n)), n))}; /* Michael Somos, Sep 25 2003 */
from gmpy2 import divexact A001006 = [1, 1] for n in range(2, 10**3): A001006.append(divexact(A001006[-1]*(2*n+1)+(3*n-3)*A001006[-2],n+2)) # Chai Wah Wu, Sep 01 2014
def mot(): a, b, n = 0, 1, 1 while True: yield b//n n += 1 a, b = b, (3*(n-1)*n*a+(2*n-1)*n*b)//((n+1)*(n-1)) A001006 = mot() print([next(A001006) for n in range(30)]) # Peter Luschny, May 16 2016
# A simple generator of Motzkin-paths (see the first comment of David Callan). C = str.count def aGen(n: int): a = [""] for w in a: if len(w) == n: if C(w, "U") == C(w, "D"): yield w else: for j in "UDF": u = w + j if C(u, "U") >= C(u, "D"): a += [u] return a for n in range(6): MP = [w for w in aGen(n)]; print(len(MP), ":", MP) # Peter Luschny, Dec 03 2024
G.f. = 1 + x + 3*x^2 + 11*x^3 + 45*x^4 + 197*x^5 + 903*x^6 + 4279*x^7 + ... a(2) = 3: abc, a(bc), (ab)c; a(3) = 11: abcd, (ab)cd, a(bc)d, ab(cd), (ab)(cd), a(bcd), a(b(cd)), a((bc)d), (abc)d, (a(bc))d, ((ab)c)d. Sum over partitions formula: a(3) = 2*a(0)*a(2) + 1*a(1)^2 + 3*(a(0)^2)*a(1) + 1*a(0)^4 = 6 + 1 + 3 + 1 = 11. a(4) = 45 since the top row of Q^3 = (11, 14, 12, 8, 0, 0, 0, ...); (11 + 14 + 12 + 8) = 45.
a001003 = last . a144944_row -- Reinhard Zumkeller, May 11 2013
R:=PowerSeriesRing(Rationals(), 50); Coefficients(R!( (1+x -Sqrt(1-6*x+x^2) )/(4*x) )); // G. C. Greubel, Oct 27 2024
t1 := (1/(4*x))*(1+x-sqrt(1-6*x+x^2)); series(t1,x,40); invtr:= proc(p) local b; b:= proc(n) option remember; local i; `if`(n<1, 1, add(b(n-i) *p(i-1), i=1..n+1)) end end: a:='a': f:= (invtr@@2)(a): a:= proc(n) if n<0 then 1 else f(n-1) fi end: seq(a(n), n=0..30); # Alois P. Heinz, Apr 01 2009 # Computes n -> [a[0],a[1],..,a[n]] A001003_list := proc(n) local j,a,w; a := array(0..n); a[0] := 1; for w from 1 to n do a[w] := a[w-1]+2*add(a[j]*a[w-j-1],j=1..w-1) od; convert(a,list) end: A001003_list(100); # Peter Luschny, May 17 2011
Table[Length[Flatten[Nest[ #/.a_Integer:> Join[Range[0, a + 1], Range[a, 0, -1]] &, {0}, n]]], {n, 0, 10}]; Sch[ 0 ] = Sch[ 1 ] = 1; Sch[ n_Integer ] := Sch[ n ] = (3(2n - 1)Sch[ n - 1 ] - (n - 2)Sch[ n - 2 ])/(n + 1); Array[ Sch, 24, 0] (* Second program: *) a[n_] := Hypergeometric2F1[-n + 1, n + 2, 2, -1]; a[0] = 1; Table[a[n], {n, 0, 23}] (* Jean-François Alcover, Nov 09 2011, after Vladeta Jovovic *) a[ n_] := SeriesCoefficient[ (1 + x - Sqrt[1 - 6 x + x^2]) / (4 x), {x, 0, n}]; (* Michael Somos, Aug 26 2015 *) Table[(KroneckerDelta[n] - GegenbauerC[n+1, -1/2, 3])/4, {n, 0, 20}] (* Vladimir Reshetnikov, Oct 25 2015 *) a[n_] := -LegendreP[n, -1, 2, 3] I / Sqrt[2]; a[0] = 1; Table[a[n], {n, 0, 23}] (* Jean-François Alcover, Feb 16 2019 *) a[1]:=1; a[2]:=1; a[n_]:=a[n] = a[n-1]+2 Sum[a[k] a[n-k], {k,2,n-1}]; Map[a, Range[24]] (* Oliver Seipel, Nov 03 2024, after Schröder 1870 *) CoefficientList[InverseSeries[Series[x/(Series[(1 - x)/(1 - 2 x), {x, 0, 24}]), {x, 0, 24}]]/x, x] (* Mats Granvik, Jun 30 2025 *)
{a(n) = if( n<1, n==0, sum( k=0, n, 2^k * binomial(n, k) * binomial(n, k-1) ) / (2*n))}; /* Michael Somos, Mar 31 2007 */
{a(n) = my(A); if( n<1, n==0, n--; A = x * O(x^n); n! * simplify( polcoef( exp(3*x + A) * besseli(1, 2*x * quadgen(8) + A), n)))}; /* Michael Somos, Mar 31 2007 */
{a(n) = if( n<0, 0, n++; polcoef( serreverse( (x - 2*x^2) / (1 - x) + x * O(x^n)), n))}; /* Michael Somos, Mar 31 2007 */
N=30; x='x+O('x^N); Vec( (1+x-(1-6*x+x^2)^(1/2))/(4*x) ) \\ Hugo Pfoertner, Nov 19 2018
# The objective of this implementation is efficiency. # n -> [a(0), a(1), ..., a(n)] def A001003_list(n): a = [0 for i in range(n)] a[0] = 1 for w in range(1, n): s = 0 for j in range(1, w): s += a[j]*a[w-j-1] a[w] = a[w-1]+2*s return a # Peter Luschny, May 17 2011
from gmpy2 import divexact A001003 = [1, 1] for n in range(3,10**3): A001003.append(divexact(A001003[-1]*(6*n-9)-(n-3)*A001003[-2],n)) # Chai Wah Wu, Sep 01 2014
# Generalized algorithm of L. Seidel def A001003_list(n) : D = [0]*(n+1); D[1] = 1/2 b = True; h = 2; R = [1] for i in range(2*n-2) : if b : for k in range(h,0,-1) : D[k] += D[k-1] h += 1; else : for k in range(1,h, 1) : D[k] += D[k-1] R.append(D[h-1]); b = not b return R A001003_list(24) # Peter Luschny, Jun 02 2012
del[m_,n_]:=If[Mod[n,m]==0,1,0]; R[n_]:=If[n<3, 0, (n^4-6n^3+23n^2-42n+24)/24 + del[2,n](-5n^3+42n^2-40n-48)/48 - del[4,n](3n/4) + del[6,n](-53n^2+310n)/12 + del[12,n](49n/2) + del[18,n]*32n + del[24,n]*19n - del[30,n]*36n - del[42,n]*50n - del[60,n]*190n - del[84,n]*78n - del[90,n]*48n - del[120,n]*78n - del[210,n]*48n]; Table[R[n], {n,1,1000}] (* T. D. Noe, Dec 21 2006 *)
/* Only for odd n > 3, not suitable for other values of n! */ { a(n)=local(nr,x,fn,cn,fn2); nr=0; fn=floor(n/2); cn=ceil(n/2); fn2=(fn-1)^2-1; nr=fn2*n+fn+(n-2)*fn+cn; x=(n-5)/2; if (x>0,nr+=x*(x+1)*(2*x+1)/6*n); nr; } \\ Jon Perry, Jul 08 2003
apply( {A007678(n)=if(n%2, (((n-6)*n+23)*n-42)*n/24+1, ((n^3/2 -17*n^2/4 +22*n -if(n%4, 31, 40) +!(n%6)*(310 -53*n))/12 +!(n%12)*49/2 +!(n%18)*32 +!(n%24)*19 -!(n%30)*36 -!(n%42)*50 -!(n%60)*190 -!(n%84)*78 -!(n%90)*48 -!(n%120)*78 -!(n%210)*48)*n)}, [1..44]) \\ M. F. Hasler, Aug 06 2021
def d(n,m): return not n % m def A007678(n): return (1176*d(n,12)*n - 3744*d(n,120)*n + 1536*d(n,18)*n - d(n,2)*(5*n**3 - 42*n**2 + 40*n + 48) - 2304*d(n,210)*n + 912*d(n,24)*n - 1728*d(n,30)*n - 36*d(n,4)*n - 2400*d(n,42)*n - 4*d(n,6)*n*(53*n - 310) - 9120*d(n,60)*n - 3744*d(n,84)*n - 2304*d(n,90)*n + 2*n**4 - 12*n**3 + 46*n**2 - 84*n)//48 + 1 # Chai Wah Wu, Mar 08 2021
del[m_,n_]:=If[Mod[n,m]==0,1,0]; Int[n_]:=If[n<4, n, n + Binomial[n,4] + del[2,n](-5n^3+45n^2-70n+24)/24 - del[4,n](3n/2) + del[6,n](-45n^2+262n)/6 + del[12,n]*42n + del[18,n]*60n + del[24,n]*35n - del[30,n]*38n - del[42,n]*82n - del[60,n]*330n - del[84,n]*144n - del[90,n]*96n - del[120,n]*144n - del[210,n]*96n]; Table[Int[n], {n,1,1000}] (* T. D. Noe, Dec 21 2006 *)
apply( {A007569(n)=A006561(n)+n}, [1..44]) \\ M. F. Hasler, Aug 06 2021
def d(n,m): return not n % m def A007569(n): return 2 if n == 2 else n*(42*d(n,12) - 144*d(n,120) + 60*d(n,18) - 96*d(n,210) + 35*d(n,24)- 38*d(n,30) - 82*d(n,42) - 330*d(n,60) - 144*d(n,84) - 96*d(n,90)) + (n**4 - 6*n**3 + 11*n**2 + 18*n -d(n,2)*(5*n**3 - 45*n**2 + 70*n - 24) - 36*d(n,4)*n - 4*d(n,6)*n*(45*n - 262))//24 # Chai Wah Wu, Mar 08 2021
1 + x + x^2 + 2*x^3 + 5*x^4 + 13*x^5 + 35*x^6 + 97*x^7 + 275*x^8 + ... a(3)=2 because the only Dyck paths of semilength 3 with no UUDD in them are UDUDUD and UUDUDD (the nonqualifying ones being UDUUDD, UUDDUD and UUUDDD). - _Emeric Deutsch_, Jan 27 2003
a082582 n = a082582_list !! n a082582_list = 1 : 1 : f [1,1] where f xs'@(x:_:xs) = y : f (y : xs') where y = x + sum (zipWith (*) xs' $ reverse xs) -- Reinhard Zumkeller, Nov 13 2012
f:= gfun:-rectoproc({(n-1)*a(n)+(2*n+4)*a(n+2)+(-14-4*n)*a(n+3)+(5+n)*a(n+4), a(0) = 1, a(1) = 1, a(2) = 1, a(3) = 2},a(n),remember): map(f,[$0..100]); # Robert Israel, May 20 2016
a[0]=1;a[n_Integer]:=a[n]=a[n-1]+Sum[a[k]*a[n-1-k],{k,2,n-1}];Table[a[n],{n,0,40}] (* Vladimir Joseph Stephan Orlovsky, Mar 30 2011 *) a[ n_] := SeriesCoefficient[ 2 / (1 + x^2 + Sqrt[1 - 4 x + 2 x^2 + x^4]), {x, 0, n}] (* Michael Somos, Jul 01 2011 *) a[n_] := Sum[HypergeometricPFQ[{-k, 3 + k, k - n}, {1, 2}, 1], {k, 0, n}]; Join[{1, 1}, Table[a[n], {n, 0, 26}]] (* Peter Luschny, Oct 18 2020 *)
a(n):=sum(sum((binomial(n-k-2,j)*binomial(k,j)*binomial(k+j+2,j))/(j+1),j,0,n-k-1),k,0,n-2); /* Vladimir Kruchinin, Oct 18 2020 */
{a(n) = polcoeff( (1 + x^2 - sqrt( 1 - 4*x + 2*x^2 + x^4 + x^2 * O(x^n))) / 2, n+1)} /* Michael Somos, Jul 22 2003 */
{a(n) = if( n<0, 0, polcoeff( 2 /(1 + x^2 + sqrt( 1 - 4*x + 2*x^2 + x^4 + x * O(x^n))),n))} /* Michael Somos, Jul 01 2011 */
{a(n) = local(A); if( n<0, 0, A = O(x); for( k = 0, n, A = 1 / (1 + x^2 - x * A)); polcoeff( A, n))} /* Michael Somos, Mar 28 2011 */
G.f. = x*(1 + x + 4*x^2 + 23*x^3 + 156*x^4 + 1162*x^5 + 9192*x^6 + 75819*x^7 + ...).
A007297:=proc(n) if n = 1 then 1 else add(binomial(3*n - 3, n + j)*binomial(j - 1, j - n + 1), j = n - 1 .. 2*n - 3)/(n - 1); fi; end;
CoefficientList[ InverseSeries[ Series[(x-x^2)/(1+x)^3, {x, 0, 20}], x], x] // Rest (* From Jean-François Alcover, May 19 2011, after PARI prog. *) Table[Binomial[3n, 2n+1] Hypergeometric2F1[1-n, n, 2n+2, -1]/n, {n, 1, 20}] (* Vladimir Reshetnikov, Oct 25 2015 *)
a(n)=if(n<0,0,polcoeff(serreverse((x-x^2)/(1+x)^3+O(x^(n+2))),n+1)) /* Ralf Stephan */
delta:=(m,n) -> if (n mod m) = 0 then 1 else 0; fi; f:=proc(n) global delta; if n <= 2 then 0 else \ binomial(n,4) \ + (-5*n^3 + 45*n^2 - 70*n + 24)*delta(2,n)/24 \ - (3*n/2)*delta(4,n) \ + (-45*n^2 + 262*n)*delta(6,n)/6 \ + 42*n*delta(12,n) \ + 60*n*delta(18,n) \ + 35*n*delta(24,n) \ - 38*n*delta(30,n) \ - 82*n*delta(42,n) \ - 330*n*delta(60,n) \ - 144*n*delta(84,n) \ - 96*n*delta(90,n) \ - 144*n*delta(120,n) \ - 96*n*delta(210,n); fi; end; [seq(f(n),n=1..100)]; # N. J. A. Sloane, Aug 09 2017
del[m_,n_]:=If[Mod[n,m]==0,1,0]; Int[n_]:=If[n<4, 0, Binomial[n,4] + del[2,n](-5n^3+45n^2-70n+24)/24 - del[4,n](3n/2) + del[6,n](-45n^2+262n)/6 + del[12,n]*42n + del[18,n]*60n + del[24,n]*35n - del[30,n]*38n - del[42,n]*82n - del[60,n]*330n - del[84,n]*144n - del[90,n]*96n - del[120,n]*144n - del[210,n]*96n]; Table[Int[n], {n,1,1000}] (* T. D. Noe, Dec 21 2006 *)
apply( {A006561(n)=binomial(n,4)+if(n%2==0, (n>2) + (-5*n^2+45*n-70)*n/24 + vecsum([t[2] | t<-[4,6,12,18,24,30,42,60,84,90,120,210;-3/2,(262-45*n)/6,42,60,35,-38,-82,-330,-144,-96,-144,-96], n%t[1]==0])*n)}, [1..44]) \\ M. F. Hasler, Aug 23 2017, edited Aug 06 2021
def d(n,m): return not n % m def A006561(n): return 0 if n == 2 else n*(42*d(n,12) - 144*d(n,120) + 60*d(n,18) - 96*d(n,210) + 35*d(n,24)- 38*d(n,30) - 82*d(n,42) - 330*d(n,60) - 144*d(n,84) - 96*d(n,90)) + (n**4 - 6*n**3 + 11*n**2 - 6*n -d(n,2)*(5*n**3 - 45*n**2 + 70*n - 24) - 36*d(n,4)*n - 4*d(n,6)*n*(45*n - 262))//24 # Chai Wah Wu, Mar 08 2021
del[m_, n_] := Boole[Mod[n, m] == 0]; A007569[n_] := If[n < 4, n, n + Binomial[n, 4] + del[2, n] (-5 n^3 + 45 n^2 - 70 n + 24)/24 - del[4, n] (3 n/2) + del[6, n] (-45 n^2 + 262 n)/6 + del[12, n]*42 n + del[18, n]*60 n + del[24, n]*35 n - del[30, n]*38 n - del[42, n]*82 n - del[60, n]*330 n - del[84, n]*144 n - del[90, n]*96 n - del[120, n]*144 n - del[210, n]*96 n]; A007678[n_] := If[n < 3, 0, (n^4 - 6 n^3 + 23 n^2 - 42 n + 24)/24 + del[2, n] (-5 n^3 + 42 n^2 - 40 n - 48)/48 - del[4, n] (3 n/4) + del[6, n] (-53 n^2 + 310 n)/12 + del[12, n] (49 n/2) + del[18, n]*32 n + del[24, n]*19 n - del[30, n]*36 n - del[42, n]*50 n - del[60, n]*190 n - del[84, n]*78 n - del[90, n]*48 n - del[120, n]*78 n - del[210, n]*48 n]; a[n_] := A007569[n] + A007678[n] - 1; Array[a, 40] (* Jean-François Alcover, Sep 07 2017, after Max Alekseyev, using T. D. Noe's code for A007569 and A007678 *)
The sequence of terms together with their multiset multisystems begins: 2117: {{1,3},{2,4}} 3973: {{1,3},{2,5}} 4234: {{},{1,3},{2,4}} 4843: {{1,3},{2,6}} 5183: {{1,1,3},{2,4}} 5249: {{1,3},{1,2,4}} 5891: {{1,4},{2,5}} 6351: {{1},{1,3},{2,4}} 6757: {{1,3},{2,7}} 7181: {{1,4},{2,6}} 7801: {{1,3},{2,8}} 7946: {{},{1,3},{2,5}} 8249: {{2,4},{1,2,3}} 8468: {{},{},{1,3},{2,4}} 8903: {{1,3},{2,2,4}} 9193: {{1,3},{1,2,5}} 9686: {{},{1,3},{2,6}} 9727: {{1,1,3},{2,5}}
Comments