Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Ok so i have numbers from 1 to 100000.I need to remove the zeroes from all numbers and sum up numbers from 1 to 100000.So if the number is 405 consider it as 45 , if number if 20039 consider it 239. Is there any mathematical way to solve this, i mean any formula or anything.

share|improve this question
    
Probably the best way is to do this with help from a computer. There seems to be no good way to do this without a computer. –  Djaian Mar 26 '13 at 8:09
    
i agree with dat. But that would require looping from 1 to 100000.I'm trying to find out if there is any other mathematical way to do this without looping –  iJay Mar 26 '13 at 8:23

3 Answers 3

up vote 18 down vote accepted

It's slightly more natural to consider the numbers from $1$ to $99999$, since they form complete sets of numbers with a certain number of digits; we can then add $1$ for $100000$ in the end.

There are $\displaystyle\binom5k$ ways to select $k$ of the $5$ digits to be non-zero, and they all lead to the same numbers when the zeros are removed. Every non-zero digit can take the values $1$ through $9$, whose sum is $9(9+1)/2=45$. The digits can be chosen independently, so the total for $k$ non-zero digits is $45$ for a given digit times $9^{k-1}$ options for the remaining digits times $\underbrace{1\ldots1}_k=(10^k-1)/9$ for the sum of the valencies of the digits, for a grand total of

$$ \begin{align} \sum_{k=0}^5\binom5k45\cdot9^{k-1}\frac{10^k-1}9 &= \frac59\left(\sum_{k=0}^5\binom5k90^k-\sum_{k=0}^5\binom5k9^k\right) \\ &= \frac59\left(91^5-10^5\right) \\ &=3466789695\;. \end{align} $$

Add the $1$ for $100000$, and the result coincides with Mark's.

share|improve this answer
1  
oh! Turns out there was a way to do this without a computer... Nice ! –  Djaian Mar 26 '13 at 9:20

Given the Mathematica flag, you might consider posting this type of question on mathematica.stackexchange.com. Nonetheless,

deleteZeros[n_] := FromDigits[DeleteCases[IntegerDigits[n], 0]];
Total[deleteZeros /@ Range[100000]]

(* Out: 3466789696 *)
share|improve this answer

Look. You may ask how many numbers in 1-100000 end with 5 (the looks like xxxxx5 where $x \in \{0,...9\}$) let it be $a_{15}$ , then how many numbers looks like xxxx5x let it be $a_{25}$ and so on . After that you should add all $a_{ij}$, were $i\in\{1,2,3,4,5\}$ and $j\in\{1,...9\}$.

share|improve this answer

Your Answer

 
discard

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.