I need to write a program in python that given an integer as input calculates the digit in a continuous row of natural numbers starting by 1 and continuing to infinite(ex. 12345678910111213141516171819202122 etc...) So for example if we input 17 it calculates the 17th digit in this row, which is 3.
I have written a program that can calculate till the 189th digit but I need to make it for very big number(till position 2**31-1)
def digit_finder():
if pos < 10: #Position is equal to digit.
digit=pos
return(digit)
elif pos >= 10 en pos < 189: #Number between 10 and 99.
number=(pos-9)
if pos%2==0:
new_number=(10+(number//2))
digit=(new_number//10)
return digit
else:
new_number=(9+(number//2))
digit=(new_number-((new_number//10)*10))
return digit
I don't know how to continue it for bigger numbers. Please help !