%I #9 Mar 25 2016 23:23:51
%S 0,1,3,6,19,69,399,1999,9999,99999,1999999,39999999,699999999,
%T 19999999999,699999999999,39999999999999,1999999999999999,
%U 99999999999999999,9999999999999999999,1999999999999999999999
%N a(n+1) is the smallest integer such that the difference between its digital sum and the digital sum of a(n) is n.
%C The digital sums are the triangular numbers A000217. A similar idea is in A268605 (thanks to Michel Marcus for this comment).
%e a(8) = 1999 and 1 + 9 + 9 + 9 = 28; so a(9) = 9999 because 9 + 9 + 9 + 9 = 36 and 36 - 28 = 8.
%o (Python)
%o s = 0
%o for i in range(1,100):
%o ..alfa = ""
%o ..k = i + s
%o ..s = k
%o ..while k > 9:
%o ....alfa = alfa + "9"
%o ....k = k - 9
%o ..alfa = str(k)+alfa
%o ..print alfa
%o (PARI) findnext(x, k) = {sx = sumdigits(x); y = 1; while (sumdigits(y) - sx != k, y++); y; }
%o lista(nn) = {print1(x = 0, ", "); for (k=1, nn, y = findnext(x, k); print1(y, ", "); x = y; ); }
%Y Cf. A000217, A268605.
%K nonn,base
%O 1,3
%A _Francesco Di Matteo_, Feb 23 2016
|