A060712 Smallest number whose sum of digits is 3^n.
1, 3, 9, 999, 999999999, 999999999999999999999999999, 999999999999999999999999999999999999999999999999999999999999999999999999999999999
Offset: 0
Links
- Harry J. Smith, Table of n, a(n) for n = 0..8
Crossrefs
Cf. A051885.
Programs
-
Mathematica
Do[ a = {}; While[ Apply[ Plus, a ] + 9 < 3^n, a = Append[ a, 9 ] ]; If[ Apply[ Plus, a ] != 3^n, a = Prepend[ a, 3^n - Apply[ Plus, a ] ] ]; Print[ FromDigits[ a ] ], {n, 1, 6} ] Join[{1,3},Table[FromDigits[PadRight[{},3^(n-2),9]],{n,2,6}]] (* Harvey P. Dale, Jun 10 2015 *)
-
PARI
a(n)={ my(s=3^n, x=s\9, d=s-9*x); (d+1)*10^x - 1 } \\ Harry J. Smith, Jul 10 2009
Formula
a(n) = A051885(3^n). - Andrew Howroyd, Dec 08 2024
a(n) = 10^(3^(n-2)) - 1 for n > 1. - Stefano Spezia, Mar 27 2025