A004049 Erroneous version of A006967.
1, 1, 4, 4, 8, 24, 32, 40, 120, 296
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.
For n=3 we have 1-3-2 and 2-1-3, so a(3)=2.
{ treedet(v, n) = n=length(v); matdet(matrix(n,n,i,j, if(i-j,-v[abs(i-j)], sum(m=1,n+1,if(i-m,v[abs(i-m)],0))))) } { graceful_tree_count(n, s,v,v1,v0)= if(n==1,1, s=0; v1=vector(n-1,m,1); v0=vector(n-1,m,if(m==1,1,0)); for(m=2^(n-2),2^(n-1)-1, v= binary(m) - v0; s = s + (-1)^(v*v1~) * treedet(v1-2*v) ); s/2^(n-2) ) } \\ Noam D. Elkies, Nov 18 2002 for(n=1,18,print1(graceful_tree_count(n),", ")) \\ Example of function call
For n=7 and i=3, g(7,3) = 1080. For n=7 and i=5, g(7,5) = 960. Triangle begins: [n\i] [1] [2] [3] [4] [5] [6] [7] [8] [2] 0; [3] 1, 1; [4] 4, 4, 4; [5] 18, 24, 24, 18; [6] 96, 144, 144, 144, 96; [7] 600, 960, 1080, 1080, 960, 600; [8] 4320, 7200, 8640, 8640, 8640, 7200, 4320; [9] 35280, 60480, 75600, 80640, 80640, 75600, 60480, 35280; ... - _Bruno Berselli_, Apr 23 2014
/* As triangle: */ [[i le Floor(n/2) select Factorial(n-2)*(n-1-i)*i else Factorial(n-2)*(n-i)*(i-1): i in [1..n-1]]: n in [2..10]]; // Bruno Berselli, Apr 23 2014
Labeled:=(i,n) piecewise(n<2 or i<1, -infinity, 1 <= i <= floor(n/2), GAMMA(n-1)*(n-1-i)*i, ceil((n+1)/2) <= i <= n-1, GAMMA(n-1)*(n-i)*(i-1), infinity):
n=10; (* This number must be replaced every time in order to produce the different entries of the sequence *) For[i = 1, i <= Floor[n/2], i++, g[n_,i_]:=(n-2)!*(n-1-i)*i; Print["g(",n,",",i,")=", g[n,i]]] For[i = Ceiling[(n+1)/2], i <= (n-1), i++, g[n_,i_]:=(n-2)!*(n-i)*(i-1); Print["g(",n,",",i,")=",g[n,i]]]
a(3)=2 as only 123 and 321 have the required property, with differences of 1,1. The rest all have differences of 1,2.
A006967 = Cases[Import["https://oeis.org/A006967/b006967.txt", "Table"], {, }][[All, 2]]; a[n_] := n! - A006967[[n+1]]; a /@ Range[40] (* Jean-François Alcover, Jan 31 2020 *)
{ for (n=3,10,x=vector(n-1); s=0; for (i=1,n!,v=numtoperm(n,i); for (j=1,n-1,x[j]=abs(v[j+1]-v[j])); x=vecsort(x); fl=0; for (k=1,n-2,if (x[k]==x[k+1],fl=1; break)); if (fl==1,s++)); print(n"; "s)) }
For n = 6 the a(6) = 12 solutions are 162534, 251643, 316254, 325164, 342516, 346152, 431625, 435261, 452613, 461523, 526134, 615243.
Triangle begins: n\k 1 2 3 4 ------------------------------- 1: 1 2: 2 16 3: 4 128 5728 4: 4 1416 580728 758857152
Comments