# How to know difference between sum of numbers?

If all the $6$ are replaced by $9$, then the algebraic sum of all the numbers from 1 to $100$ (both inclusive) varies by?

Question - What is the difference between algebraic sum of numbers(with $6$ and when $6$ is replaced by $9$)?

Answer - Answer is $330$

I can do it manually but in exam time is limited and it take time to add these numbers, So I want to know that how can I solve it quickly and what if the range is big like $1$ to $1000$ how to solve it quickly?

-

Hint: Find out the number of times $6$ occurs in units place and tens place.Then calculate the difference when $6$ is replaced by $9$. You can calculate the difference as follows:

(difference between digits)x(number of occurrences)x(place value)

Units place : It occurs $10$ times - $6,16,...,96$. The difference is : $(9-6)*10*1 = 30$

Tens place : It again occurs $10$ times - $60,61,...,69$. The difference is : $(9-6)*10*10 = 300$

Total difference encountered : $30+300=330$

Same is the case with numbers in the range $1$ to $1000$ except that in this case you need to take care of the digits in hundred's place as well.

-

Every time it happens in units place, it causes a difference of $3*9=27$ (excluding $60-69$)

For $60-69$,it causes a difference of $30$ for every replacement, so $30*10+3=303$ ($10$ replacements in ten's digit and one replacement in units digit)

Hence, total difference = $303+27=330$

-
Why do you exclude $60-69$ for the units ? It doesn't change anything. –  Traklon Feb 4 '14 at 11:49
Basically I have done the same. I just wanted to make it sound simple. else the units difference would have been 30 and the tens 330, just where am adding the units 3 difference in 60-69 changes, nothing else. But yes you are right –  Bhargav Feb 4 '14 at 11:56
@Bhargav Here it doesn't matter much as it just makes your solution little bigger. But the way you did might help in solving some other questions. Anyways good observation. –  lsp Feb 4 '14 at 11:59