A358620 Number of nonzero digits needed to write all nonnegative n-digit integers.
9, 171, 2520, 33300, 414000, 4950000, 57600000, 657000000, 7380000000, 81900000000, 900000000000, 9810000000000, 106200000000000, 1143000000000000, 12240000000000000, 130500000000000000, 1386000000000000000, 14670000000000000000, 154800000000000000000
Offset: 1
Examples
a(1) = 9 because there are 9 one-digit numbers that are > 0. a(2) = 171 because there are 90 two-digit numbers, so 90*2 = 180 digits are needed to write these integers, nine of these integers end with 0, and 180-9 = 171.
Links
- Index entries for linear recurrences with constant coefficients, signature (20,-100).
Programs
-
Maple
seq((9*(9*n+1))*10^(n-2), n = 1 .. 20);
-
Mathematica
a[n_] := 9*(9*n + 1)*10^(n - 2); Array[a, 20] (* Amiram Eldar, Nov 23 2022 *)
-
PARI
a(n)=(81*n+9)*10^(n-2) \\ Charles R Greathouse IV, Nov 29 2022
-
Python
def A358620(n): return 9 if n == 1 else 9*(9*n+1)*10**(n-2) # Chai Wah Wu, Nov 29 2022