[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A324376
Number of permutations p of [n] whose absolute displacements |p(i)-i| are factorial numbers.
4
1, 0, 1, 2, 4, 6, 13, 48, 149, 286, 832, 2304, 6560, 13630, 35937, 95816, 242496, 586480, 1492057, 3928292, 10019073, 24819960, 63656169, 163618614, 416809221, 1731461192, 6214212533
OFFSET
0,4
EXAMPLE
a(2) = 1: 21.
a(3) = 2: 231, 312.
a(4) = 4: 2143, 2413, 3142, 3412.
a(5) = 6: 21453, 21534, 23154, 24153, 31254, 31524.
a(6) = 13: 214365, 214635, 215364, 215634, 231564, 231645, 241365, 241635, 312564, 312645, 314265, 315264, 341265.
MAPLE
g:= proc(n) local i; 1; for i from 2 do
if n=% then true; break elif n<% then false; break fi;
%*i od; g(n):=%
end:
b:= proc(s) option remember; (n-> `if`(n=0, 1, add(`if`(
g(abs(n-j)), b(s minus {j}), 0), j=s)))(nops(s))
end:
a:= n-> b({$1..n}):
seq(a(n), n=0..20);
MATHEMATICA
factorialQ[n_] := factorialQ[n] = Module[{i, k = 1}, For[i = 2, True, i++, If[n == k, Return[True]]; If[n < k, Return[False]]; k = k*i]];
b[s_] := b[s] = With[{n = Length[s]}, If[n == 0, 1, Sum[If[factorialQ[Abs[n - j]], b[s ~Complement~ {j}], 0], {j, s}]]];
a[n_] := b[Range[n]];
a /@ Range[0, 20] (* Jean-François Alcover, Mar 25 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Feb 25 2019
STATUS
approved