|
|
A116983
|
|
Position of n! among the lexicographically ordered permutations of digits of n!.
|
|
1
|
|
|
1, 1, 1, 1, 1, 4, 6, 11, 54, 150, 648, 5013, 9849, 19345, 1060707, 10939036, 4343045, 2498014850, 5271260976, 78029366100, 531495923280, 805809810981, 1936900666393, 28724010464057580, 29052364970866225, 75805259574286872, 7466893805506395652, 80374513001512054041
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,6
|
|
LINKS
|
|
|
EXAMPLE
|
a(5)=4 because 5!=120 and {1,2,0} is the 4th of the 6 permutations of {0,1,2} when listed in lexicographical order: {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}}.
a(14)=1060707 because 14!=87178291200 and {8,7,1,7,8,2,9,1,2,0,0} is the 1060707th of the 1247400 permutations of {0,0,1,1,2,2,7,7,8,8,9} when listed in lexicographical order.
|
|
MAPLE
|
for y to 1000 do N:=y!:s:=floor(log10(N))+1:a:=array(1..10): for i to 10 do a[i]:=0:od: c:=array(1..s):for j to s do c[j]:=floor(N/10^(j-1))-10*floor(N/10^j):od: for i to s do k:=c[i]:a[k+1]:=a[k+1]+1:od: q:=1:p:=s!/(a[10]!*a[1]!*a[2]!*a[3]!*a[4]!*a[5]!*a[6]!*a[7]!*a[8]!*a[9]!): for j from s by -1 to 2 do p:=p/j; r:=c[j]; if r>0 then for t from 0 to r-1 do if a[t+1]>0 then q:=q+p*a[t+1]:fi:od:fi:p:=p*a[r+1]:a[r+1]:=a[r+1]-1:od:print(y, N, q):od: # Anatoly Kazmerchuk, Jun 06 2009
f:= proc(X)
local L, Lp, T, d, i, t;
if nops(X) = 1 then return 1 fi;
L:= [seq(numboccur(i, X), i=0..9)];
T:= 0;
for d from 0 to X[1]-1 do
if L[d+1] > 0 then
Lp:= L - [0$d, 1, 0$(9-d)];
T:= T + convert(Lp, `+`)!/mul(t!, t=Lp);
fi
od:
T + procname(X[2..-1]);
end proc:
seq(f(ListTools:-Reverse(convert(n!, base, 10))), n=1..50); # Robert Israel, Dec 22 2014
|
|
MATHEMATICA
|
Do[per=Permutations[Sort[tn=IntegerDigits[n! ]]]; Print[Position[per, tn]], {n, 0, 14}]
lst={}; Do[p=Permutations[Sort[i=IntegerDigits[n! ]]]; AppendTo[lst, FromDigits[FromDigits[Position[p, i]]]], {n, 0, 14}]; lst (* Vladimir Joseph Stephan Orlovsky, May 12 2010 *)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|