A011540 Numbers that contain a digit 0.
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 301, 302
Offset: 1
Examples
a(10) = 90. a(100) = 540. a(10^3) = 4005. a(10^4) = 30501. a(10^5) = 253503. a(10^6) = 2165031. a(10^7) = 20163807 a(10^8) = 182915091. a(10^9) = 1688534028. a(10^10) = 15749319096. a(10^20) = 114131439770460123393. a(10^50) = 10057979971082351274741...89870962249 = 1.0057979971082...*10^50 a(10^100) = 10000298815737485...786424499 = 1.0000298815737...*10^100. a(10^1000) = 1...(45 zeros)...196635515818798306...4244999 (1001 digits), using recursive calculation. - _Hieronymus Fischer_, Jan 13 2013
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- Index entries for 10-automatic sequences.
Crossrefs
Programs
-
Haskell
a011540 n = a011540_list !! (n-1) a011540_list = filter ((== 0) . a168046) [0..] -- Reinhard Zumkeller, Apr 07 2011
-
Magma
[0] cat [ n: n in [0..350] | 0 in Intseq(n) ]; // Vincenzo Librandi, Oct 12 2015
-
Mathematica
Select[Range[0, 299], DigitCount[#, 10, 0] > 0 &] (* Alonso del Arte, Mar 10 2011 *) Select[Range[0, 299], Times@@IntegerDigits[#] == 0 &] (* Alonso del Arte, Aug 29 2014 *)
-
PARI
is(n)=!n||!vecmin(digits(n)) \\ M. F. Hasler, Feb 28 2018, replacing an earlier version from Charles R Greathouse IV, Aug 09 2011
-
PARI
A011540(n)=my(m=log(n+.5)\log(10)+1, f(m)=n-10^m+(9*9^m-17)/8, j=(sign(f(m)+1)+1)\2+m-1, c=[f(j)], k=1); while(c[k]>0,c=concat(c,c[k] % (10^(j-k+1) - 9^(j-k+1)) - 10^(j-k));k++); k>1&&k--||n>1||return(0); c[k]%(10^(j-k+1) - 9^(j-k+1)) + sum(i=1,k, (c[i]\(10^(j-i+1) - 9^(j-i+1)) + 1)*10^(j-i+1)) \\ Uses the "Direct calculation" formula given by H. Fischer. - M. F. Hasler, Oct 11 2015
-
Python
A011540_list = [n for n in range(10**3) if '0' in str(n)] # Chai Wah Wu, Mar 26 2021
-
Smalltalk
A011540 "Calculates the n-th number with zero digits recursively - not optimized" | n j m b d p r | n := self. n < 2 ifTrue: [^r := 0]. m := (n integerFloorLog: 10) + 1. j := (n + 1 - ((10 raisedToInteger: m) - (((9 raisedToInteger: (m + 1)) - 17) // 8))) sign + 1 // 2 + m - 1. d := (10 raisedToInteger: j) - (9 raisedToInteger: j). b := ((10 raisedToInteger: j) - (((9 raisedToInteger: (j + 1)) - 17) // 8)). (((n - b) \\ d > (10 raisedToInteger: (j - 1))) and: [n >= 19]) ifTrue: [p := (((n - b) \\ d + b - d) A011540)]. (n - b) \\ d > (10 raisedToInteger: (j - 1)) ifFalse: [p := (n - b) \\ d]. r := (((n - b) // d + 1) * (10 raisedToInteger: j)) + p. ^r "Hieronymus Fischer, Jan 13 2013"
-
Smalltalk
A011540_inverse "Version 1: Answers the index n such that A011540(n) = m, where m is the receiver. Usage: m A011540_inverse Answer: n" | m p q s r d | m := self. m < 10 ifTrue: [^1]. p := q := 1. [p < m] whileTrue: [d := m // p \\ 10. d = 0 ifTrue: [q := p]. p := 10 * p]. r := m \\ q. s := r + 2. p := 10. q := 1. m := m - r - 1. [p < m] whileTrue: [s := m // p * q + s. p := 10 * p. q := 9 * q]. ^s "Hieronymus Fischer, May 28 2014"
-
Smalltalk
A011540_inverse "Version 2: Answers the index n such that A011540(n) = m, where m is the receiver. Uses A052382_inverse from A052382. Usage: m A011540_inverse Answer: n" | m p q d | m := self. m < 10 ifTrue: [^1]. p := q := 1. [p < m] whileTrue: [d := m // p \\ 10. d = 0 ifTrue: [q := p]. p := 10 * p]. ^m + 1 - (m - 1 - (m \\ q)) A052382_inverse "Hieronymus Fischer, May 28 2014"
Formula
From Hieronymus Fischer, Jan 13 2013: (Start)
Inequalities:
a(n) <= 10*(n - 1), equality holds for 1 <= n <= 11.
a(n) <= 9*n, for n <> 11.
a(n) < n + 10 * n^log_10(9).
a(n) < n + 2 * n^log_10(9), for n > 6*10^8.
a(n) > n + 9^log_10(9)/8 * n^log_10(9).
a(n) < A043489(n), for n > 10.
Iterative calculation:
a(n+1) = a(n) + 1 + 9*sign(A007954(a(n)+1)).
Recursive calculation (for n > 1):
Set m := floor(log_10(n)) + 1), j := floor(sign(n+1 - (8*10^m - 9*9^m + 17)/8) + 1)/2) + m - 1, d := 10^j - 9^j, b := (8*10^j - 9*9^j + 17)/8, and determine r(n) as follows:
Case 1: r(n) = a(b - d + (n - b) mod d), if (n - b) mod d > 10^(j-1) and n >= 19
Case 2: r(n) = (n - b) mod d, if (n - b) mod d <= 10^(j-1).
Then a(n) = (floor((n - b)/d) + 1)*10^j + r(n).
Direct calculation (for n>1):
Set m := floor(log_10(n)) + 1), j := floor((sign(n+1 - (8*10^m - 9*9^m + 17)/8) + 1)/2) + m - 1, and determine k and c(i) as follows:
c(1) = n - (8*10^j - 9*9^j + 17)/8, then define successively for i = 1, 2, ...,
c(i+1) = (c(i) mod (10^(j-i+1) - 9^(j-i+1))) - 10^(j-i) while this value is > 0, and set k := i for the last such index for which c(i) > 0 (in any case k is k<=j).
Then a(n) = c(k) mod (10^(j-k+1) - 9^(j-k+1)) + sum_{i=1..k}(floor(c(i)/(10^(j-i+1) - 9^(j-i+1))) + 1)*10^(j-i+1).
Asymptotic behavior:
a(n) = n + O(n^log_10(9)) = n*(1+ O(1/n^0.04575749056...)).
lim a(n)/n = 1 for n -> infinity.
lim inf (a(n) - n)/n^log_10(9) = 9^log_10(9)/8 = 1.017393081085670008926619124438...
lim sup (a(n) - n)/n^log_10(9) = 9/8 = 1.125.
Sums:
Sum_{n >= 2} (-1)^n/a(n) = 0.0693489578....
Sum_{n >= 2} 1/a(n)^2 = 0.0179656962...
Sum_{n >= 2} 1/a(n) diverges, because of a(n) < 10*n.
Sum_{n >= 1} a(n)/n^2 diverges too.
Sum_{n >= 2} 1/a(n)^2 + Sum_{n >= 1} 1/A052382(n)^2 = Pi^2/6.
Generating function:
g(x) = Sum_{k >= 1} g_k(x), where the terms g_k(x) obey the following recurrence relation:
g_k(x) = 10^k*x^b(k) * (1 - 10x^(9d(k)) + 9x^(10d(k)))/((1-x^d(k))(1-x)) + (x*x^b(k) * (1 - 10^(k-1)*x^(10^(k-1)-1) + (10^(k-1)-1)*x^10^(k-1))/((1-x)^2) + g_(k-1)(x)*x^d(k)) * (1-x^(9d(k)))/(1-x^d(k)),
where b(k) := 2 + 10^k - 9^k - (9^k-1)/8,
d(k) := 10^k - 9^k, and g_0(x) = 0.
Explicit representation of g_k(x):
g_k(x) = (10^k*x^b(k)*(1 - 10x^(9d(k)) + 9x^(10d(k)))/(1-x^d(k)) + sum_{j=1..k-1} ((10^j*x^b(j) * (1 - 10x^(9d(j)) + 9x^(10d(j)))/(1-x^d(j)) + x^(b(j)-10^j+1) * (1 - 10^j*x^(10^j-1) + (10^j-1)*x^10^j)/(1-x)) * Product_{i=j+1..k} x^d(i)*(1-x^(9d(i)))/(1-x^d(i)))/(1-x).
A summation term g_k(x) of the g.f. represents all the sequence terms >= 10^k and < 10^(k+1).
Example 1: g_1(x) = 10*x^2*(1 - 10x^9 + 9x^10)/(1-x)^2 represents the g.f. fragment 10x^2 + 20x^3 + ... + 90x^10 and so generates the terms a(2)=10 ... a(10)=90.
Example 2: g_2(x) = 10^2*x^11*(1 - 10x^(9*19) + 9x^(10*19))/((1-x)(1-x^19)) + 10*x^21 * (1 - 10x^9 + 9x^10)/((1-x)^2) * (1-x^(9*19))/(1-x^19)) + x^11*x * (1 - 10x^9 + 9x^10)/((1-x)^2) * (1-x^(9*19))/(1-x^19) represents the g.f. fragment 100x^11 + 101x^12 + ... + 109x^20 + 110x^21 + 120x^22 + ... + 190x^29 + 200x^30 + 201x^31 + ... + 210x^40 + ... + 990x^181 and so generates the terms a(11) = 100 ... a(181) = 990.
(End)
From Hieronymus Fischer, Feb 12 2019: (Start)
The number C(n) of zero-containing numbers <= n (counting function) is given by C(n) = A011540_inverse(n), if n is a zero-containing number, and C(n) = A011540_inverse(A052382(a(n) + 1 - n)), if n is a zerofree number.
Upper bound:
C(n) <= n+1-((9*n+1)^d-1)/8.
Lower bound:
C(n) > n+1-((10*n+1)^d-1)/8
where d = log_10(9) = 0.95424250943932...
(see A324160).
(End)
Extensions
Edited by M. F. Hasler, Oct 11 2015
Comments