Basically, the question asks us to find the nth digit in the following sequence:


where the 10th digit is $1$, the 11th digit is $0$, etc.

EDIT: Here are my workings: I was thinking about defining intervals in some way, for example, I know that there are 9 digits in this interval $0\dots9$ and $10\dots99$, and later try to find a sum. However, I am stuck on this point.

  • $\begingroup$ Although it is OK to ask and answer your own question, I can't up-vote this, as you should at least show an effort to answer in the question. +1 for the answer though. $\endgroup$
    – JMCF125
    Commented Jan 3, 2014 at 19:19

1 Answer 1


Consider a function $g(n)$, which is defined as: $$g(n)=\sum_{1\leqslant k \leqslant n} 9 \times 10^{k-1} \times k = \frac{ 9(n+1)10^n-10^{n+1}+1} {9} \qquad k,n \in \mathbb{Z^+}$$ You will probably see that the values can be calculated quite easily since there is a pattern: $$g(1)=9$$ $$g(2)=189$$ $$g(3)=2889$$ $$g(4)=38889$$ Now, given we want to find the $n$th digit we have to first solve $p$: $$ p=10^{\lceil a \rceil} -1 - \left\lfloor \frac{g( \lceil a \rceil) - g(a)}{\lceil a \rceil} \right\rfloor, g(a) = n \qquad a \in \mathbb{R^+}$$

This, $p$, will give us the number that contains the $n$th digit. So, in order to find the $n$th digit, calculate:

$$r = g(\lceil a \rceil ) - g(a) \mod \lceil a \rceil $$ The $r$ gives you the index of the $n$th digit in the number $p$.

$$p = (a_r\dots a_1a_0)$$

Reference: Los., Artem. (2014). Finding the nth digit in a sequence of positive integers placed in a row in ascending order.. Available: https://myows.com/protects/copyright/67407_mathexploration-pdf. Last accessed 3rd Jan 2014.

  • 1
    $\begingroup$ @Artem To quote from the help center: "You should only ask practical, answerable questions based on actual problems that you face." There is no exception for hats. $\endgroup$ Commented Jan 3, 2014 at 22:21
  • 1
    $\begingroup$ This answer is cool, but you should expand more the explanations. $\endgroup$ Commented Mar 26, 2015 at 16:48

Not the answer you're looking for? Browse other questions tagged .