A164321
Let s(n) be the smallest number x such that the decimal representation of n appears as a substring of the decimal representations of the numbers [0...x] more than x times.
Original entry on oeis.org
199991, 28263828, 371599993, 499999994, 5555555555, 6666666666, 7777777777, 8888888888, 9999999999
Offset: 1
Closely related to
A163500 substituting > for = as suggested by Alexey Radul. The first term is given in the related
A092175 which also generalizes the sequence for bases other than 10.
-
;; This is a program in PLT Scheme, a.k.a. mzscheme
(define (count-matches re str start-pos)
(let ((m (regexp-match-positions re str start-pos)))
(if m (+ 1 (count-matches re str (+ (caar m) 1))) 0)))
(define (matches-n-in-zero-to-k fn n)
(do ((sum-so-far 1)
(k (+ n 1))
(re (regexp (format "~a" n))))
((fn sum-so-far k) k)
(when (equal? 0 (modulo k 1000000))
(display (format "~a ~a ~a\n" n k sum-so-far)))
(set! k (+ k 1))
(set! sum-so-far
(+ sum-so-far (count-matches re (format "~a" k) 0)))))
(define (s n)
(matches-n-in-zero-to-k > n))
A164935
a(n) is the smallest number x such that the decimal representation of n appears as a substring of the decimal representations of the numbers [1...x] >= x times.
Original entry on oeis.org
100559404366, 1, 28263827, 371599983, 499999984, 5555555555, 6666666666, 7777777777, 8888888888, 9999999999, 109999999999999999999999999999999999999999999999999999999999999999999999999999999999999999810
Offset: 0
-
cz[n_, k_] := Floor[n/10^k] 10^(k - 1) + (Ceiling[Floor[n/10^(k - 1)]/10] - Floor[Floor[n/10^(k - 1)]/10] - 1) (10^(k - 1) - Mod[n, 10^(k - 1)] - 1) countZeroes[n_] := (z = 0; k = 1; len = Length[IntegerDigits[n]]; While[k < len, z = z + cz[n, k]; k++ ]; z) c = 8; d = 16; While[d - c > 1 , If[countZeroes[d] >= c, d = (c + d)/2, {c, d} = {d, d + 2 d - 2 c}]]; While[ countZeroes[c] < c, c++ ]; Print[c] countAny[n_, anyK_] := (z = 0; lenK = Length[IntegerDigits[anyK]]; len = Length[IntegerDigits[n]]; k = lenK;
While[k <= len, middle = Mod[Floor[n/10^(k - lenK)], 10^lenK]; If [middle > anyK, z = z + ( Floor[n/10^k] + 1) 10^(k - lenK)]; If[middle < anyK, z = z + Floor[n/10^k] 10^(k - lenK)]; If[middle == anyK, z = z + Floor[n/10^k] 10^(k - lenK) + Mod[n, 10^(k - lenK)] + 1]; k++ ]; z) i = 1; c = 8; d = 16; While[i < 20, While[d - c > 1 , If[countAny[d, i] >= c, d = (c + d)/2, {c, d} = {d, d + 2 d - 2 c}]]; While[countAny[c, i] < c, c++ ]; Print[c]; d = c + 8; i++ ]
Showing 1-2 of 2 results.
Comments