login
a(n) is the largest number which can be formed with no zeros, using least number of digits and having digit sum = n.
2

%I #12 Aug 16 2023 08:20:09

%S 1,2,3,4,5,6,7,8,9,91,92,93,94,95,96,97,98,99,991,992,993,994,995,996,

%T 997,998,999,9991,9992,9993,9994,9995,9996,9997,9998,9999,99991,99992,

%U 99993,99994,99995,99996,99997,99998,99999,999991,999992,999993,999994

%N a(n) is the largest number which can be formed with no zeros, using least number of digits and having digit sum = n.

%C a(n) is the digit reversal of terms of A051885 giving such smallest numbers.

%H Michael S. Branicky, <a href="/A061219/b061219.txt">Table of n, a(n) for n = 1..9000</a>

%e a(22) = 994, digit sum = 22.

%e a(100) = 999999999991.

%t dsn[n_]:=Module[{d=Quotient[n,9]},FromDigits[PadLeft[{n-9d},d,9]]]; If[Divisible[#,10],#/10,#]&/@Array[dsn,50,10] (* _Harvey P. Dale_, Dec 08 2013 *)

%o (Python)

%o def a(n): return int("9"*(n//9)+str(n%9)*(n%9>0))

%o print([a(n) for n in range(1, 50)]) # _Michael S. Branicky_, Aug 16 2023

%Y Cf. A051885.

%K nonn,base

%O 1,2

%A _Amarnath Murthy_, Apr 22 2001

%E More terms from _Harvey P. Dale_, Dec 08 2013

%E Offset corrected by _Michael S. Branicky_, Aug 16 2023