Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two problems which are based on the sequence $A007376$.

  1. Natural numbers starting with $1$ are written one after another like $123456789101112131415\cdots$, how could we find the $10^4$th digit from left?
  2. A hundred digit number is formed by writing the first $x$ natural numbers one after another as $123456789101112131415\cdots$, how to find the remainder when this number is divided by $8$?

The OEIS doesn't provide any formula that could be implemented into a under a minute solution,as this is a quantitative aptitude problem, I was wondering which is the fastest way to approach?

share|cite|improve this question
up vote 5 down vote accepted

There are $9$ one-digit numbers, giving the first $9$ digits.

Then there are $90$ two-digit numbers, giving the next $180$ digits; total, $189$ digits, so far.

There are $900$ three-digit numbers, giving $2700$ digits, total $2889$.

To get to $ 10,000$, you need another $7111$, which is $7108/4=1777$ four-digit numbers, and the first $3$ digits of the $1778$th four-digit number. You should be able to figure out what those are.

For the hundred digit number, same process, then remember that the remainder on division by $8$ depends only on the last $3$ digits.

share|cite|improve this answer
@MaX Just for the sake of completeness, $12345\cdots545= 12345\cdots\times 100 + 545$ and so $12345\cdots545\mod 8 = (12345\cdots\mod 8)\times (100\mod 8) + (545\mod 8) \mod 8 = 545\mod 8$ since $100\mod 8 = 0\mod 8$. – Alex Becker Dec 29 '11 at 4:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.