%I #29 Jun 04 2016 06:59:57
%S 1,2,4,33,5,46,6,2,2,3,2,2,6
%N Concatenate the digits of the natural numbers from 1 to n in order to build up two numbers x and y that minimize the ratio x/y > 0, an integer (leading zeros not admitted).
%C For n=8 and n=9 we have 12 possible different fractions:
%C n=8 -> 3456/1728, 3528/1764, 3564/1782, 3654/1827, 4356/2178, 4716/2358, 5436/2718, 5634/2817, 7128/3564, 7164/3582, 8352/4176, 8712/4356.
%C n=9 -> 13458/6729, 13584/6792, 13854/6927, 14538/7269, 14586/7293, 14658/7329, 15384/7692, 15846/7923, 15864/7932, 18534/9267, 18546/9273, 18654/9327. - _Arie Groeneveld_, Nov 25 2011
%C Examples for n=10..13: a(10) = 3 = 161427/53809, a(11) = 2 = 1141826/570913, a(12) = 2 = 11418226/5709113, and a(13) = 6 = 114312678/19052113. - _Giovanni Resta_, May 31 2016
%e Starting with a(1)=1 we have a(2)=2/1=2, a(3)=12/3=4, a(4)=132/4=33, a(5)=215/43=5, a(6)= 2346/51= 46, a(7)= 3426/571=6, a(8)= 3456/1728 = 2, a(9)= 13458/6729=2.
%p with(combinat,permute);
%p P:=proc(i)
%p local a,c,d,j,k,m,ok,n,t,v,x,y;
%p v:=[1,2]; t:=2; lprint(1,1); lprint(2,2);
%p for n from 3 to i do
%p c:=n;
%p for j from 1 to floor(1+evalf(log10(n))) do
%p t:=t+1; v:=[op(v),c-10*trunc(c/10)]; c:=trunc(c/10);
%p od;
%p if (t mod 2)=1 then a:=(t+1)/2; else a:=t/2; fi;
%p c:=permute(v); d:=nops(c); c:=op(c); m:=10^13; ok:=0;
%p while ok=0 do
%p for j from 1 to d do
%p x:=0; for k from 1 to a do x:=10*x+c[j][k]; od;
%p y:=0; for k from a+1 to t do y:=10*y+c[j][k]; od;
%p if x>y then if trunc(x/y)=x/y then ok:=1; if x/y<m then m:=x/y; if m=2 then break; fi; fi; fi; fi;
%p od;
%p if ok=0 then a:=a+1; fi;
%p od;
%p lprint(n,m);
%p od;
%p end:
%p P(10);
%K nonn,base,hard,more
%O 1,2
%A _Paolo P. Lava_, Nov 25 2011
%E a(5) corrected by _Arie Groeneveld_, Nov 25 2011
%E a(6)-a(9) from _Claudio Meller_, Nov 25 2011
%E a(10)-a(13) from _Giovanni Resta_, May 31 2016
|