%I #7 Sep 23 2019 14:48:10
%S 1,10,2,11,100,3,101,12,102,110,20,21,111,1000,4,1001,13,1002,103,
%T 1003,1010,22,1011,112,1012,1020,120,121,1021,1100,30,200,31,1101,201,
%U 202,1102,1110,210,211,1111,10000,5,10001,14,10002,104,10003,1004,10004,10010
%N Lexicographically earliest sequence of distinct positive terms such that for any k > 0, the sum of the first k digits does not exceed k.
%C The sequence is a permutation of the natural numbers:
%C - we can always extend the sequence with a power of 10 that has not yet appeared,
%C - every power of 10 appears in the sequence,
%C - for any n > 0 with digital sum s: n can appear after any number of the form 10^k with k+1 >= s, hence n will eventually appear.
%H Rémy Sigrist, <a href="/A327689/a327689.gp.txt">PARI program for A327689</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F Sum_{i = 1..n} A007953(a(n)) <= Sum_{i = 1..n} A055642(a(n)).
%e The first terms, alongside the corresponding digits and sum of digits, are:
%e n a(n) k d(k) s(k)
%e -- ---- -- ---- ----
%e 1 1 1 1 1
%e 2 10 2 1 2
%e 3 0 2
%e 3 2 4 2 4
%e 4 11 5 1 5
%e 6 1 6
%e 5 100 7 1 7
%e 8 0 7
%e 9 0 7
%e 6 3 10 3 10
%o (PARI) See Links section.
%Y Cf. A007953, A055642.
%K nonn,base
%O 1,2
%A _Rémy Sigrist_, Sep 22 2019