%I #45 Mar 02 2019 02:15:41
%S 1,1,1,4,3,2,2,3,14,1358,1,1,1,17,8,8,7,6,679,58,1,1,1,44,5,4,47,786,
%T 4,38,4,71,35,34,3,6,617,3,29,259,3,271,5,47,5,2716,22,26,25,229,2,2,
%U 231,4,393,2,2,193,19,19,2,2,181,194,33,34,17,3,15,29,3,31,1696,14,3,16,145
%N a(n) is the smallest positive number such that the decimal digits of n*a(n) are all 0, 1 or 2.
%C Records occur for n: 1, 3, 8, 9, 45, 89, 99, 495, 998, ..., . [_Robert G. Wilson v_, Oct 04 2010]
%H Robert G. Wilson v, <a href="/A181061/b181061.txt">Table of n, a(n) for n = 0..100000</a> (first 20000 terms and some terms up to 100000 from Victor Maslov)
%H Victor Maslov, <a href="/A181061/a181061_1.png">Log-log plot for n = 0..20000</a>
%H Project Euler, <a href="http://projecteuler.net/index.php?section=problems&id=303">Problem 303: Multiples with small digits</a>
%F If a(n)=k, then a(10n)=k. [_Robert G. Wilson v_, Oct 04 2010]
%e a(9)=1358 because 9*1358=12222 is the smallest multiple of 9 whose decimal digits are all 0, 1 or 2.
%t f[n_] := Block[{id = {0, 1, 2}, k = 1}, While[ Union@ Join[id, IntegerDigits[k*n]] != id, k++ ]; k]; Array[f, 76] (* _Robert G. Wilson v_, Oct 04 2010 *)
%o (PARI) a(n)=my(k=n,t);while(1,t=vecsort(eval(Vec(Str(k))),,8);if(t[#t]<3,return(k/n),k+=n)) \\ _Charles R Greathouse IV_, Sep 05 2011
%o (PARI) anydiggt2(n)=if(n<2,0,while(n>0,if(n%10>2,return(1));n\=10);0)
%o a(n)={local(prd,ms=[],rems=[],msn,remsn,pow=10,maxm);
%o if(n<=0,return(0));
%o while(n%10==0,n\=10);
%o maxm=if(n%10==5,5,if(n%2==1,3,4));
%o for(d=1,9,if(!anydiggt2(prd=d*n),return(d));
%o if(prd%10<=2,ms=concat(ms,[d]);rems=concat(rems,[prd\10])));
%o while(1,
%o msn=listcreate(maxm*#ms);remsn=listcreate(maxm*#ms);
%o for(d=0,9,
%o for(k=1,#ms,
%o if(!anydiggt2(prd=d*n+rems[k]),return(d*pow+ms[k]));
%o if(prd%10<=2,listput(msn,d*pow+ms[k]);listput(remsn,prd\10))));
%o ms=Vec(msn);rems=Vec(remsn);pow*=10;print1("."))}
%Y n*a(n) yields sequence A181060.
%K base,nonn
%O 0,4
%A _Herman Beeksma_, Oct 01 2010
|