Why counting the number of 1 digits that appear in all integers in 0-9, 0-99, 0-999, 0-9999 follow an arithemtic-geometric sequence?

396 Views Asked by At

I noticed that

  • 0-9 = has only 1 '1'
  • 0-99 = has 20 '1's [1,10,11,12,13,14,15,16,17,18,19,21,31,41,51,61,71,81,91]
  • 0-999 = 300
  • 0-9999 = 4000

It follows the formula of

  • n = number of digits in the sequence
  • Formula : n*(10**(n-1))

I don't see why.

I hope the question is well formatted

1

There are 1 best solutions below

1
On BEST ANSWER

For the purpose of this question, let's consider that a number between $0$ and $999...9$ = $10^n-1$ ($n$ digits $9$) is always written with $n$ digits, by adding leading zeros when necessary.

Then all numbers from $0$ to $10^n-1$ included are the combinations of digits from $0$ to $9$ in $n$ places. The $1$ on digit $k$ is present on $10^{n-1}$ numbers, exactly on one-tenth of all numbers. As there are $n$ digits, there are $n 10^{n-1}$ digits $1$ in total.

Another way of saying it: with the leading zeros, there is a same quantity of each digit. As there are $10^n$ numbers of $n$ digits each, this makes a total of $n 10^n$ digits, where one tenth of that, i.e. $n 10^{n-1}$, are $1$.