If you write all the whole numbers upto 100000, the number of times you write the digit '1' is A and the number of times you write the digit '2' is B. what is the value of A-B ?
Note : if you write 11 , then you will count it as writing '1' twice.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
It seems that till 9 9 9 9 9 , all the digits are degenerate (Chemistry term for equal energy orbitals, here used for equal probability) . While writing 1 0 0 0 0 0 , we will write digit 1 extra time, so A − B = 1
Thank you for this extra (chemistry) vocabulary.
For the units digit, a 1 will appear once every 10 numbers --> 0.1 of the time.
For the tens digit, a 1 will appear 10 times every 100 numbers --> 0.1 of the time.
For the hundreds digit, a 1 will appear 100 times every 1000 numbers --> 0.1 of the time...
Number of 1s = 10^5, plus the 1 in 100000, so 100001 ones appear.
The same goes for 2s, but there is no 2 in the number 100000, so 2 appears 100000 times.
A - B = 100001 - 100000 = 1
Not the easiest way to do it, but yes that is a valid explanation.
Python 2.7:
1 2 3 4 5 6 |
|
This one is easily solvable with the following observation: for numbers 1 through 99999, the number of 1s and 2s is equal. To verify that this is true, it suffices to check that the function that takes a number between 1 and 99999, swaps every 1 in that number with a 2, and vice versa, is bijective.
We are then left with 100000, which gives us a-b=1.
Let f(n) be the number obtained by replacing the digit 1 in n with the digit 2, and vice versa. Then f is a bijection on {1,...,99999}, so A-B=1.
1 will be written the same times as 2 from 1 to 99999. A − B = 1 because of 100000.
Problem Loading...
Note Loading...
Set Loading...
Every time we write a 1 , it is accompanied by a 2
But we have an extra number 1 0 0 0 0 0 and thus A − B = 1