Menu
Coddy logo textTech

Digit

Lesson 28 of 32 in Coddy's Coding Problems course.

challenge icon

Challenge

Hard

You are given a sequence which begins with 1 and after every element the added sequence increases, but it starts over, as following:

    112123123412345123456

 

Given a natural number N from input. Return the N-th digit of the given sequence.

 

Input
10

Output
4

Input
17

Output
2

Explanation #2: 1121231234123451[2]34561234567

Try it yourself

int digit(int a1) {
    // Write code here
}

All lessons in Coding Problems