cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A081927 n-th positive integer whose digits sum up to n.

This page as a plain text file.
%I A081927 #14 Mar 02 2024 13:37:47
%S A081927 1,11,21,31,41,51,61,71,81,109,137,165,193,257,294,376,467,567,676,
%T A081927 785,894,1399,1778,1986,2887,3869,4869,5878,6887,7896,8959,9968,18798,
%U A081927 26998,35999,45999,56899,66989,76998,87799,97889,178899,199798,298988,398988
%N A081927 n-th positive integer whose digits sum up to n.
%H A081927 Robert Israel, <a href="/A081927/b081927.txt">Table of n, a(n) for n = 1..8989</a>
%F A081927 From _Robert Israel_, Feb 20 2018: (Start)
%F A081927 a(9*k-j) = (12-j)*10^(k-1) - 10^(k-10) - 10^(j+k-45) - 1 for j=2..9, k >= 45-j.
%F A081927 a(9*k-1) = 2*10^k - 10^(k-9) - 10^(k-35) - 1, k >= 35. (End)
%e A081927 31 is the 4th integer of the sequence and the 4th number whose digits sum up to 4 : 4, 13, 22, [31], 103, 112, 121, 130, ...
%e A081927 109 is the 10th integer of the sequence and the 10th number whose digits sum up to 10 : 19, 28, 37, 46, 55, 64, 73, 82, 91, [109], 118, 127, 136, ...
%p A081927 f:= proc(n) local Res, d, v, count;
%p A081927     count:= 0;
%p A081927     for d from ceil(n/9) while count < n do
%p A081927        v:= g(n,d,n-count,1);
%p A081927        Res:= v[-1];
%p A081927        count:= count + nops(v);
%p A081927     od:
%p A081927     Res
%p A081927 end proc:
%p A081927 g:= proc(n,d,remain) local rem, Res, j, j0, v;
%p A081927       if remain = 0 then return [] else rem:= remain fi;
%p A081927       if nargs = 4 then j0:= 1 else j0:= 0 fi;
%p A081927       if d = 1 then if n >= j0 and n <= 9 then [n] else [] fi
%p A081927       else
%p A081927         Res:= NULL;
%p A081927         for j from max(j0, ceil(n-9*(d-1))) to min(9,n) while rem > 0 do
%p A081927           v:= map(t -> j*10^(d-1)+t, procname(n-j,d-1,rem));
%p A081927           Res:= Res, op(v);
%p A081927           rem:= rem - nops(v);
%p A081927         od;
%p A081927         [Res]
%p A081927       fi
%p A081927 end proc:
%p A081927 map(f, [$1..200]); # _Robert Israel_, Feb 19 2018
%t A081927 Table[Select[Range[500000],Total[IntegerDigits[#]]==n&][[n]],{n,45}] (* _Harvey P. Dale_, Mar 02 2024 *)
%Y A081927 Leading diagonal of A081926.
%Y A081927 Cf. A081928, A181178
%K A081927 base,nonn
%O A081927 1,2
%A A081927 _Amarnath Murthy_, Apr 01 2003
%E A081927 Corrected and extended by _Ray Chandler_, Oct 29 2003