5
$\begingroup$

I've seen the question for numbers like 50, 100 or 1000, but not for $n$. Although I found a formula that might be the answer, but I don't know the name of it or the proof for it. I couldn't find it anywhere on internet as well. Here it is: $$d\times(n+1) - \frac{10^d - 1}{9}$$ $d$ is the number of digits $n$ has.

For example, for $n = 16$:

Answer: $\displaystyle2\times (16 + 1) - \frac{10^2 - 1}{9} = 34 - 11 = 23$

Also: $12345678910111213141516\rightarrow 23 \text{ digits}$

Looking forward for replies!

Thanks!

Edit 1: For those who also want to know how $d$ is calculated: $d = \lfloor\log_{10}n\rfloor + 1$

$\endgroup$
2
  • 1
    $\begingroup$ Interesting result, but it doesn’t seem useful so you’re probably the first one to make this formula. $\endgroup$ Commented Nov 21, 2022 at 20:46
  • $\begingroup$ It'd be nice if you'd include an explanation as to how you derived that. If you include that in your body, I will delete my answer. It really should be your explanation as it was your idea. $\endgroup$
    – fleablood
    Commented Nov 21, 2022 at 21:30

1 Answer 1

3
$\begingroup$

Well, it's clear we write down a "ones" digit for each $n$. And we write down a "tens" digit for all but the first $9$ so we do $n-9$ "tens" digits. And $n-99$ hundreds digits and so on.

So if $d$ is the number of digits as you put it, we have the number of digits written is.

$n + (n-9) + (n-99) + ...... + (n-\underbrace{999....9}_{d-1})=$

$n\times d - (9 + 99 + ..... + \underbrace{999....9}_{d-1})=$

$n\times d- ((10-1) + (100-1) + ...... + (10^d -1))=$

$n\times d - [(10 + 100 + ..... + 10^{d-1}) -(d-1)]=$

$n\times d - [(10 + 100 + ..... + 10^{d-1})+1] + d=$

$n\times d + d - [1+10 + 100 + ..... + 10^{d-1}] =$

$(n+1)\times d - [\underbrace{111.....1}_d] =$

$(n+1)\times d - \frac {10^{d}-1}9$

Nice job!

$\endgroup$
2
  • $\begingroup$ I'll delete this if you include your derivation. It really should be your explanation. $\endgroup$
    – fleablood
    Commented Nov 21, 2022 at 21:31
  • $\begingroup$ Thank you so much! this proof is what I was looking for! <3 $\endgroup$
    – Alixsep
    Commented Nov 22, 2022 at 16:41

You must log in to answer this question.

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