OFFSET
1,2
LINKS
Project Euler, Problem 305: Reflexive Position
PROG
(Python)
def a(n):
# a(n) is the starting position of the n-th occurrence of n in
# the string 123456789101112131415161718192021 .
full='~'+''.join(map(str, range(1, 10000)))
def place(n, str_n, offset):
p=full[offset:].find(str_n)+offset
return p if n==1 else place(n-1, str_n, p+1)
return place(n, str(n), 0)
# prints the first fifty terms
print(', '.join(str(a(i)) for i in range(1, 51)))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jon Palin (jon.palin(AT)gmail.com), Oct 15 2010
STATUS
approved