Mr. Snow was bored and started writing all the positive integers starting with 1, as one long sequence, i.e 123456789101112131415... What was the 2018th digit of his sequence?
Please explain!!!

Respuesta :

Consider this list
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
11, 12, 13, 14, 15, ...

In that list, there are...
A) 9 numbers that are single digit: 1 through 9
B) 90 numbers that are two digits: 10 through 99
C) 900 numbers that are three digits: 100 through 999
D) 9000 numbers that are four digits: 1000 through 9999
The pattern continues

Focus on fact (A) above. We have 9 digits to start with. So we take that away from 2018 to get 2018-9 = 2009

Then we have 90 numbers which are two digits (fact B above). So overall for this group, there are 90*2 = 180 single-digit values here. Subtract this from the previous result to get 2009-180 = 1829

Then move onto fact C. There are 900 triple digit numbers so 900*3 = 2700 digits overall. The result 2700 is larger than the previous result of 1829. What does this mean? It means that the answer will come from a digit from a number between 100 through 999.

--------------------------------------

Now consider this new list
100, 101, 102, ..., 998, 999
basically the set of whole numbers from 100 to 999

We have 1829 digit spots to work with. Group those into groups of 3 to get 1829/3 = 609 remainder 2
The 609 is the quotient. The 609 tells us we have 609 whole groups of 3. The remainder 2 is the amount left over that couldn't form a whole group.
So we have 609

The first value is 100, the second is 101 and so on. 
We have this mapping going on
1 --> 100
2 --> 101
3 --> 102
...
609 --> 708
610 --> 709
To go from the left side of the mapping to the right side, we add on 99 (eg: 1 to 100 is plus 99)

The answer will come from the digits of 709. Specifically it will be the second digit of 709 as 2 was the remainder above.

The second digit of 709 is 0.

------------------------------------------------------------------------------------------------------------------------------------------------

Final Answer: 0