login
A084894
Number of permutations of length n such that at least one absolute difference between consecutive elements has a distinct partner.
2
0, 0, 2, 20, 112, 696, 5008, 40280, 362760, 3628504, 39916152, 479000272, 6227017600, 87178281288, 1307674342408, 20922789832080, 355687427952808, 6402373705217304, 121645100407380704, 2432902008173142656, 51090942171698988176, 1124000727777569109296
OFFSET
1,3
LINKS
Jean-François Alcover, Table of n, a(n) for n = 1..40
FORMULA
a(n) = n! - A006967(n).
EXAMPLE
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.
MATHEMATICA
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 *)
PROG
(PARI) { 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)) }
CROSSREFS
Sequence in context: A069537 A282818 A001797 * A203238 A061004 A278772
KEYWORD
nonn
AUTHOR
Jon Perry, Jun 10 2003
STATUS
approved