OFFSET
1,1
COMMENTS
In typing the positive integers without leaving spaces between them, it is interesting to see how many places later we press the same number key on the keyboard. This sequence answers that question.
LINKS
Md. Towhidul Islam, Table of n, a(n) for n = 1..31968
EXAMPLE
In concatenating the positive integers, we get 1 first. The next occurrence of 1 is in 10. So 1 occurs 9 places later, which gives a(1)=9. The second digit 2 occurs again in writing 12. So 2 occurs 13 places later and a(2) is 13.
PROG
(PARI) C(nn) = {my(list = List()); for (n=1, nn, my(d=digits(n)); for (k=1, #d, listput(list, d[k]); ); ); list; } \\ A033307
posi(list, i) = {for (j=i+1, #list, if (list[i] == list[j], return (j-i)); ); }
lista(nn) = {my(list = C(nn)); my(listp = List()); for (i=1, #list, my(pos = posi(list, i)); if (! pos, break); listput(listp, pos); ); Vec(listp); } \\ Michel Marcus, Jan 11 2021
(Python)
def aupton(terms):
alst, chapnk, k = [], [1], 1
for n in range(1, terms+1):
chapn = chapnk.pop(0)
while chapn not in chapnk:
k += 1
chapnk.extend(list(map(int, str(k))))
alst.append(chapnk.index(chapn) + 1)
return alst
print(aupton(74)) # Michael S. Branicky, Sep 13 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Md. Towhidul Islam, Jan 10 2021
STATUS
approved