fork download
  1. n=9
  2. d=1
  3. pos=int(input())
  4. while True:
  5. sub=n*d
  6. if sub <= pos:
  7. pos-=sub
  8. else:
  9. break
  10. n*=10
  11. d+=1
  12. res=10**(d-1)
  13. res+=(pos//d)-(1 if pos%d==0 else 0)
  14. print((d if pos%d==0 else pos%d), end='')
  15. print("th digit of ",res," which is ", end='')
  16. pos_f=d-(d if (pos%d==0) else pos%d)
  17. while pos_f>0:
  18. res//=10
  19. pos_f-=1
  20. print(res%10)
Success #stdin #stdout 0.02s 9936KB
stdin
999999999
stdout
9th digit of  123456789  which is 9