2
$\begingroup$

Let $n$ be a natural number $k$ digits. Show that the quantity $Q$ of digits required to write the natural numbers from $1$ to $n$ is:

$Q = k(n+1) - \underbrace{111\ldots11}_{k\textrm{ digits}}$

  • 0
    Note that there are $9\cdot 10^{k-1}$ $k$-digit numbers between $10^{k-1}$ and $10^k-1$.2010-11-01
  • 0
    Close, but not quite. If you plug n=9, k=1 in (I think you are assuming n=10^k-1) it doesn't come out. You need k digits 1, not n. The usual way to write it would be to say the number of digits to write all the numbers from 1 through 10^k-1 is k(10^k)-(10^k-1)/9. This way you don't need n. Good on you for working it out.2010-11-02
  • 0
    I think the choice of whether to express the function Paulo wants in terms of $k$ or $n$ is cosmetic... :)2010-11-02

2 Answers 2

2

As this question is now 14 hours old, I will give an answer.

First sum the total number of digits of all the natural numbers $ \le k-1.$ Call this sum $S.$

There are $9 \times 10^{i-1}$ natural numbers of length $i,$ so the total number of digits of natural numbers of length $i$ is $9i \times 10^{i-1}.$ Hence

$$ S=9(1+2.10 + 3.10^2 + \cdots + (k-1)10^{k-2}) = (k-1)10^{k-1} - \frac{10^{k-1}-1}{9}.$$

Now the first natural number with $k$ digits is $10^{k-1}$ and so there are $n- 10^{k-1}+1$ natural numbers from $10^{k-1}$ to $n$ inclusive. Each of these numbers has $k$ digits and so the number of digits required to write the natural numbers from $1$ to $n$ is

$$ k( n- 10^{k-1}+1) + S = k( n- 10^{k-1}+1) + (k-1)10^{k-1} - \frac{10^{k-1}-1}{9}$$

$$ = k(n+1) - \frac{10^k-1}{9}.$$

  • 0
    Thank you, Derek! Nice resolution!2010-11-02
0

Start with the one digit numbers. How many digits are needed for them. Do you include zero? How many digits to go from 10 through 99? And so on...

  • 0
    What I want is to get a formula for the number of digits, depending on n and k.2010-11-01
  • 0
    Well, he did say 1 to n in the original question... :) @Paulo: your function will be complicated and will only depend on n, since as you know k can be obtained from n through appropriate formulae.2010-11-01
  • 0
    Yes, and with what J.M. commented and what is above, you should be able to make one. It is pretty easy to come up with one if n is 10^p-1 so you count all the p digit numbers. The expression is a little messier if you stop in the middle of a decade.2010-11-01
  • 0
    I gave the issue new writing.2010-11-02