A031297 a(n) is the least k such that the base-10 representation of n begins at s(k), where s=A007376.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 1, 16, 18, 20, 22, 24, 26, 28, 30, 15, 34, 2, 38, 40, 42, 44, 46, 48, 50, 17, 37, 56, 3, 60, 62, 64, 66, 68, 70, 19, 39, 59, 78, 4, 82, 84, 86, 88, 90, 21, 41, 61, 81, 100, 5, 104, 106, 108, 110, 23, 43, 63, 83
Offset: 1
Examples
a(1) = a(12) = a(123) = 1 since they each start at index 1 in 0123. a(21) = 15 since it appears first at index 15 in 012345678910111213.
Links
- Nathaniel Johnston, Table of n, a(n) for n = 1..10000
Crossrefs
Programs
-
Maple
with(StringTools): s:="": for n from 1 to 70 do s:=cat(s,convert(n,string)): od: seq(Search(convert(n, string), s), n=1..70); # Nathaniel Johnston, May 26 2011
-
Mathematica
nmax = 100; s = Table[IntegerDigits[n], {n, 0, nmax}] // Flatten; a[n_] := SequencePosition[s, IntegerDigits[n], 1][[1, 1]] - 1; Array[a, nmax] (* Jean-François Alcover, Feb 21 2021 *)
-
Python
from itertools import count, islice def agen(): k, chap = 0, "0" for n in count(1): target = str(n) while chap.find(target) == -1: k += 1; chap += str(k) yield chap.find(target) print(list(islice(agen(), 70))) # Michael S. Branicky, Oct 06 2022
Comments