Write the integers from 0 to 256 in the binary number base system.
In total, how many 0's are used?
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.
If the numbers 0 through 255 are written with eight bits, all possible combinations of ones and zeros are present. By symmetry, there are equal numbers of zeroes and ones. Thus we have 2 2 5 6 × 8 = 1 0 2 4 zeroes. However, we must remove leading zeroes.
There are 128 numbers where bit 7 is zero. Of these, 64 have bit 6 also equal to zero. Of those, 32 have bit 5 also equal to zero. And so on; this means that we remove 1 2 8 + 6 4 + ⋯ + 1 = 2 7 + 2 6 + ⋯ + 2 0 = 2 8 − 1 = 2 5 5 leading zeroes, so that we now have 1 0 2 4 − 2 5 5 = 7 6 9 zeroes in total.
Two things need adjusting. First, we removed all eight zeroes of 0 = 0 0 0 0 0 0 0 0 2 ; thus we add one back in. Second, we must add the eight zeroes of 2 5 6 = 1 0 0 0 0 0 0 0 0 2 . This results in the answer 7 6 9 + 1 + 8 = 7 7 8 .
At first notice that, in binary number system 256 is equal to 100000000. And it is the first nine-digit binary number.
Then notice that one-digit binary number has no zero.
Two-digit binary numbers have 1 zeros.
Three-digit binary number has 4 zeros.
Four-digit and five-digit binary numbers have 12 and 32 zeros respectively.
Here we can find a series that--
0+1+4+12+32+... ... ...
we can except 0. So the series becomes --
1+4+12+32+... ... ...
If we find the number of zeros in one to eight digit binary numbers, our work will almost done.
In the series we can see that nth term of the series is n*(2^(n-1)). So the 5th, 6th and 7th term will be 80, 192 and 448 respectively. So the sum of the first 7th term of the series is (1+4+12+32+80+192+448) or, 769.
So, the number of zeros in one to eight digit binary numbers is 769. That means if we write 1 to 255 in binary number system, we will need to write 769 zeros.
But our work is not completely done yet.
In 256, there is 8 zeros and in binary number system 0 is also 0. So we will need to write zero once more.
Total = 769+8+1
. =778
That's our answer.
I think you could be a little more elegant in making your formula. One way to make the counting since you are excluding leading zeros is "all one digit numbers" + "all two digit numbers starting with 1" + "all three digit numbers starting with 1" etc. and the remaining digits can be 0 or 1 without restriction, so a simple counting argument gets your numbers and formula without relying on a guess from the pattern.
Here's a specific one, you can make it general. First suppose we want to count how many four digit numbers there are starting with "1", like 1000 or 1101. The other three digits are either 1 or 0 without restriction, so there are 2 * 2 * 2 = 8 numbers. Since each number has 3 digits, out of those numbers there are 8 * 3 = 24 digits that are potentially "1" or "0". Because the configuration is absolutely symmetrical, there must be an equal number of "1" and "0" digits - therefore there are 24/2 = 12 zeros within the four digit numbers starting with "1".
Let us consider n-digit binary numbers. The first digit from the left can not be 0.
So there are only (n-1) spaces for 0s.
Number of binary number with n digits with left most 1 is
2
n
−
1
.
So for an n-digit number, there are
(
n
−
1
)
∗
2
n
−
1
locations to be filled.
But 0 and 1 has equal claim. So 0s possible are
2
1
∗
(
n
−
1
)
∗
2
n
−
1
=
(
n
−
1
)
∗
2
n
−
2
.
Now the number we are interested is
0
2
t
o
1
0
0
0
0
0
0
0
0
2
.
The first 0 and the last 8 0s does not fit in our formula. They are 1+8=9 0s.
Total zeros =
9
+
n
=
1
∑
8
(
n
−
1
)
∗
2
n
−
2
=
9
+
7
6
9
=
7
7
8
.
Consider all eight digit binary numbers. U need at most 7 and at least 1 zero. To find the numbers having 7 zeros is equivalent finding how many ways u can put no one given 7 empty boxes, thus ( 0 7 ) So total number of zeros used in writing these numbers is simply 7 × ( 0 7 )
To find the numbers having 6 zeros is equivalent finding how many ways u can put 1 one given 7 empty boxes, thus ( 1 7 ) . Thus the number of zeros here 6 × ( 1 7 )
We can sum up all these numbers to get the number of zeros to write an eight digit binary number. To generalise, it can be written
∑ i = 1 7 i × ( ( 7 − i ) 7 ) = 4 4 8
U can repeat this process to for 7,6, 5, …..,2 digit numbers. Finally u will get
4 4 8 + 1 9 2 + 8 0 + 3 2 + 1 2 + 4 + 1 = 7 6 9
My process is a bit tedious. I think double summation would reduce a lot of works. But i don't know it clearly. If anyone know then please explain.
Problem Loading...
Note Loading...
Set Loading...
Lemma: In base b , the number of 0's that are needed to write the numbers with exactly k ≥ 2 digits, is ( k − 1 ) × ( b − 1 ) × b k − 2 .
Proof: Consider the number of times when the ith position from the right is a 0.
For the k th position from the right, this number cannot be a 0.
Otherwise, for each of the other i = k positions, there are ( b − 1 ) possibilities for the first digit, 1 possibility for the i th digit, and b possibilities for each of the other digits. Hence, by rule of product, there are ( b − 1 ) × b k − 2 times when the i th digits is 0.
Since there are k − 1 possibilities for i , hence the number with exactly k digits will use ( k − 1 ) × ( b − 1 ) × b k − 2 zeroes.
We now apply this to the case of b = 2 .
For the positive integers that have 1 digit, none of them are 0.
For the positive integers that range from having 2 , 3 , 4 , 5 , 6 , 7 , 8 digits, the number of zeros that we use is
1 × 1 × 2 0 + 2 × 1 × 2 1 + 3 × 1 × 2 2 + 4 × 1 × 2 3 + 5 × 1 × 2 4 + 6 × 1 × 2 5 + 7 × 1 × 2 6 = 7 6 9
Now, when we account for 2 5 6 = 1 0 0 0 0 0 0 0 0 2 which has 8 zeroes, and 0 = 0 2 which has 1 zero, the number of zeroes that we use is 7 6 9 + 8 + 1 = 7 7 8 .