5
$\begingroup$

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

$\endgroup$
5
  • 3
    $\begingroup$ It isn't an arithmetic sequence (neither as a function of $n$ nor as a function of $10^n-1$). $\endgroup$ Commented Aug 1, 2022 at 19:31
  • 3
    $\begingroup$ Might be easier to count the strings that do NOT have a 1. $\endgroup$
    – Randall
    Commented Aug 1, 2022 at 19:32
  • 2
    $\begingroup$ @Randall notice that the OP counted 20, not 19 for the examples in the range 0-99. That is to say, $11$ counted twice since it had two 1's in it, not just once. Yours is a good observation if we were counting each number only once but it is unhelpful here. $\endgroup$
    – JMoravitz
    Commented Aug 1, 2022 at 19:44
  • 1
    $\begingroup$ This kind of sequence is called an arithmetico–geometric sequence. $\endgroup$
    – David K
    Commented Aug 2, 2022 at 5:43
  • 1
    $\begingroup$ @JMoravitz Your comment also answers the question why, in larger ranges, the number of 1 digits exceeds the number of numbers. $\endgroup$
    – Mr Lister
    Commented Aug 2, 2022 at 6:29

1 Answer 1

11
$\begingroup$

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$.

$\endgroup$
1
  • $\begingroup$ I understand! n slots * 1/10 of 1's per slot * 10^(n-1) numbers!! Great answer thanks. $\endgroup$
    – Zamar
    Commented Aug 2, 2022 at 8:05

You must log in to answer this question.

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