%I #15 Mar 21 2016 03:11:40
%S 0,2,2,2,2,11,8,11,11,11,299,209,74,146,407,533,623,587,1111,2621,
%T 29999,3809,20909,13043,29162,119999,38423,37037,178571,241031,
%U 2333333,645158,1874684,2030303,2352647,11142857,8333333,47027027,18418421,23025641,499999997
%N Minimum number k for which the digital sum of k*n is 2*n.
%H Chai Wah Wu, <a href="/A147822/b147822.txt">Table of n, a(n) for n = 0..79</a>
%p P:=proc(i) local j,k,n,ok,w; for n from 0 by 1 to i do j:=-1; ok:=1; while ok=1 do j:=j+1; w:=0; k:=n*j; while k>0 do w:=w+k-(trunc(k/10)*10); k:=trunc(k/10); od; if w=2*n then ok:=0; print(j); fi; od; od; end: P(100);
%t cmnk=Compile[{{n,_Integer}},Module[{k=0}, While[Total[ IntegerDigits[ k*n]] != 2n,k++];k],RuntimeAttributes -> {Listable}, Parallelization -> True]; Array[cmnk,41,0] (* _Harvey P. Dale_, Mar 01 2016 *)
%o (PARI) a(n) = {my(k = 0); while (sumdigits(k*n) != 2*n, k++); k;}; \\ _Michel Marcus_, Mar 21 2016
%Y Cf. A147823-A147831.
%K easy,nonn,base
%O 0,2
%A _Paolo P. Lava_ and _Giorgio Balzarotti_, Nov 14 2008
%E Edited by _Charles R Greathouse IV_, Nov 01 2009
%E a(35)-a(40) from _Donovan Johnson_, Sep 16 2012
|