Productive Math Class

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Today in period 8/9 math, Jerry decided to distract Mr. Ing by writing down every single natural number in the entire known universe in ascending order (it was a very long class). He's also forgotten to put some commas, and he needs your help in determining the N^\text{th} digit in his sequence (1 \le N \le 10^9). Could you be a dear and help Jerry out?

Input Specification

A single integer N (1 \le N \le 10^9).

Output Specification

The N^\text{th} digit in the sequence of all natural numbers.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2