infinite sequence n th digit





PYTHON


def funcDigit(n):

    x, y, m = 1, 1, {}

    while x <= 10:

        m[x] = y

        y = y + (10 ** x - 10 ** (x - 1)) * x

        x += 1

    for ele, foo in m.items():

        if n < foo:

            break

    ele -= 1

    y = m[ele]

    return str(10**(ele - 1)+(n-y)//ele)[(n - y) % ele]

n=int(input())

print(funcDigit(n))

Post a Comment

0 Comments