%I #21 Dec 24 2014 01:04:40
%S 1,1,1,1,1,4,6,11,54,150,648,5013,9849,19345,1060707,10939036,4343045,
%T 2498014850,5271260976,78029366100,531495923280,805809810981,
%U 1936900666393,28724010464057580,29052364970866225,75805259574286872,7466893805506395652,80374513001512054041
%N Position of n! among the lexicographically ordered permutations of digits of n!.
%H Robert Israel and Vladimir Letsko, <a href="/A116983/b116983.txt">Table of n, a(n) for n = 0..422</a> (a(0) to a(100) from Vladimir Letsko)
%e 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}}.
%e 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.
%p 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
%p f:= proc(X)
%p local L,Lp,T,d,i,t;
%p if nops(X) = 1 then return 1 fi;
%p L:= [seq(numboccur(i,X),i=0..9)];
%p T:= 0;
%p for d from 0 to X[1]-1 do
%p if L[d+1] > 0 then
%p Lp:= L - [0$d,1,0$(9-d)];
%p T:= T + convert(Lp,`+`)!/mul(t!,t=Lp);
%p fi
%p od:
%p T + procname(X[2..-1]);
%p end proc:
%p seq(f(ListTools:-Reverse(convert(n!,base,10))),n=1..50); # _Robert Israel_, Dec 22 2014
%t Do[per=Permutations[Sort[tn=IntegerDigits[n! ]]];Print[Position[per,tn]],{n,0,14}]
%t 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 *)
%K nonn,base
%O 0,6
%A _Zak Seidov_, Apr 01 2006
%E More terms from _Vladimir Letsko_, Jun 17 2009
%E Keyword "base" added by _Max Alekseyev_, Jul 03 2009
|