Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 5x 5x 5x 5x 4x 4x 4x 4x 5x 5x | export default function findNthDigit(n: number): number {
let digitLength = 1
let digitCount = 9
let num = 1
while (digitLength * digitCount < n) {
n -= digitLength * digitCount
digitLength += 1
digitCount *= 10
num *= 10
}
num += Math.floor((n - 1) / digitLength)
return num.toString().charCodeAt((n - 1) % digitLength) - '0'.charCodeAt(0)
}
|