题目:
在无限的整数序列 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …中找到第 n 个数字。
思路:
代码如下:
class Solution():
def Get_num(self, n):
if n < 0 :
print(n)
i = 0
t = n
while t:
if i ==0:
t = n-10
else:
t = n - 9 * pow(10, i) * (i+1)
if t < 0:
break
else :
n = t
i = i+1
a = n // (i+1)
b = n % (i+1)
sum = a+pow(10, i)
c = sum // pow(10, b)
c = c % 10
return c