%I #18 Jan 08 2025 13:01:33
%S 1,2,3,4,5,6,7,8,9,80,119,180,398,399,998,999,1055,1809,2715,4063,
%T 4529,11374,18180,19199,27269,54519,110549,113695,168399,294999,
%U 454511,624591,636349,639999,1090719,1818180,2350079,9639999,17576999,17914111,54545436,61484399,81818169,91728090,466359999,909091519,909113679,909156319,911363679,915636319,999999998,999999999
%N Numbers n such that the sum of the digits of the numbers from 1 to n divides the sum of the numbers from 1 to n.
%C The ratios for the numbers in the list are: 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 7, 10, 19, 19, 37, 37, 40, 67, 97, 136, 151, 325, 505, 526, 737, 1363, 2497, 2584, 3789, 6313, 9469, 12507, 12727, 12784, 20451, 33670, 43214, 154481, 280413, 284734, 814111, 905187
%C The sequence is infinite, since it contains all the numbers of the form 10^(3^k)-1 and 10^(3^k)-2. For these numbers the ratio is (10^(3^k)-1)/(9*3^k), which is an integer because in general x^(3^k)-1 can be factored into (x-1)(x^2+x+1)(x^6+x^3+1)(x^18+x^9+1)...(x^(2*3^(k-1))+x^(3^(k-1))+1) and since here x=10, x-1=9 and each of the following k factors is divisible by 3 because its sum of digits is 3, thus 10^(3^k)-1 is divisible by 9*3^k. - _Giovanni Resta_, Apr 27 2016
%F Solutions for A037123(n) | A000217(n).
%e The sum of the digits of the numbers from 1 to 80 is 648; the sum of the numbers from 1 to 80 is 80*81/2 = 3240 and 3240 / 648 = 5
%p P:=proc(q) local b,k; global a,n; a:=0; for n from 1 to q do
%p b:=n; for k from 1 to ilog10(n)+1 do a:=a+(b mod 10); b:=trunc(b/10); od;
%p if type(n*(n+1)/(2*a),integer) then print(n); fi; od; end: P(10^9);
%t With[{nn=10^9},Position[Thread[{Accumulate[Range[nn]], Accumulate[ Table[ Total[ IntegerDigits[n]],{n,nn}]]}],_?(Divisible[#[[1]],#[[2]]]&), 1,Heads->False]]//Flatten (* _Harvey P. Dale_, Sep 30 2017 *)
%o (PARI) list(lim)=my(v=List(),s,t); for(n=1,lim,s+=n; t+=sumdigits(n); if(s%t==0, listput(v,n))); Vec(v) \\ _Charles R Greathouse IV_, Apr 29 2016
%Y Cf. A000217, A037123.
%K nonn,base
%O 1,2
%A _Paolo P. Lava_, Apr 27 2016
%E a(43)-a(52) from _Charles R Greathouse IV_, Apr 29 2016