How many of the first 1000 positive integers contain the digit 0?
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.
Why is 1 being subtracted from 1 0 + 9 ( 1 9 ) = 1 8 1 ?
Log in to reply
I think the answer should be 181, and likely "1000" was forgotten. I've updated it accordingly.
why we won't consider 80 From 1 to 100 there are 10 numbers with 0 as a digit ?
Actually we need to consider 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 so there are 11 numbers with 0 as a digit right?
Log in to reply
Yeah he missed writing 80 there
Sorry, that is a typing mistake. Actually the number of digits with 0 from 1 to 100 are 10 but I forgot to write 80. Thanks for informing. I have edited my solution.
I forgot about the 1000
Log in to reply
That is the place where most them go wrong. They will be confusion whether to count 1000 or not.
Between 1-99, there are 9 x 1 of the digit 0 appearing: 10, 20, 30... 70, 80 and 90. 9 x 1 is 9.
Then, between 100,199, the digit 0 appears 1x2 (In 100) + 9x1 (101, 102, ..., 108, 109) + 9x1 (110,120, ..., 180,190) times. This is equal to: 2 + 9 + 9 times, so 20 times.
This pattern will continue 9 times, as the sequence will follow as: 100-199, 200-299, ..., 800-899 and 900-999. 20 x 9 = 180.
Finally, the 3 zeroes from 1,000 will be counted.
9 + 180 + 3 = 192 zeroes between 1-1,000.
And if you still don't believe this, go on to this site: https://www.quora.com/How-many-time-digit-0-appears-from-1-to-1000
Hope this helps.
Log in to reply
It seems you are counting both the 0 ′ s in 1 0 0 . This method is correct when the question asks for Find the number of zeros in positive integers less than 1000 ? . But here in this case the question only asks for Find the number of positive integers below 1000 containing the digit zero ?
Log in to reply
Oh... 😂😂 my fault What a mistake Thx alot Mr. Mohith
Log in to reply
@Andrew Wee – No problem. Your point is also correct. But just answered a different question. Sometimes failures for one thing gives success for another one !!!
I knew 0 wasn't negative, but not that (despite sans "-") it wasn't positive. I guess it is a bit like 12:00 AM (usually!) comes almost immediately before 12:00:01 PM. So, I prefer military time, and ask people to tell me 'noon' or 'midnight', so we don't get it wrong.
Log in to reply
In my working out - I started from 0 (since it is a positive integer), but excluded 1000, since (when you start from 0) the first 1000 integers are from 0 to 999 - so the sum works out the same. If you go from 0 to 1000, you actually count 1001 integers.
Log in to reply
Actually, 0 isn't a positive integer (esp on Brilliant). Though that statement could depend on where you are based.
I am almost certain that the UK unanimously consider 0 not-positive (and not-negative). The French consider 0 both positive and negative.
Good observation that both 0 and 1000 include 0, so it will not change the answer to the problem.
Is there an easier way? I'm really bad at maths, so I don't really get this. Can someone please help?
Log in to reply
This is the most easiest way. For better understanding I wrote every thing in detailed. Otherwise you can directly solve this number. You use you creative power at its best. You know there are 10 number which contain 0 from 1 - 100. Also you know that there are 19 numbers from 101 - 200 which contain 0. So, the total numbers are 1 0 + 9 ( 1 9 ) = 1 8 1 .
I know that you may feel this tough but once you are used to it you will find it better. The same is the case with me. When I joined brilliant I felt it very tough but after that I got used to it and now my thinking power increased a lot. Don't be discouraged !!!
Read Emil's solution about counting the complement (numbers without a 0), which I feel is an easier way to progress, though not necessarily the first approach that someone would think of.
Since the number can't begin with a zero, it is either a multiple of 1 0 (ending in a zero), or of the form a 0 b where a , b = 0 to avoid double counting numbers that fall into the first situation.
There are 1 0 1 0 0 0 = 1 0 0 multiples of 1 0 for the first situation (this goes up to and including 1 0 0 0 ).
For the second situation, there are 9 possibilities independently for a and b so there are 9 × 9 = 8 1 integers.
1 0 0 + 8 1 = 1 8 1
Such a fresh solution!
i love this method rather than simple counting. Good job!
Log in to reply
Whom do you think is simply counting ? Is it me ?
9 two-digit numbers contain zero:10,20,30,40,50,60,70,80,90. 1000 also contains zero. There are 900 three-digit numbers. Those that do not contain zero are with digits between 1 to 9. Therefore we have 9 3 =729 three-digit numbers with no zero or 900-729=171 three-digit numbers containing zero. The total of all numbers from 1 to 1000, containing zero is 9+1+171=181
"The total of all numbers between 1 and 1000." The numbers on the end of the range, are not 'between'. So, "...from 1 to 1000."
Log in to reply
I agree and it's fixed.Thank you!!!
It's easier to count the complement: all the numbers that don't contain a 0.
That means there are a total of 9 + 81 + 729 = 819 numbers that don't contain a 0. Therefore there are 1000 - 819 = 1 8 1 numbers that do contain a 0.
Cheers for contrarians! (However, 0 is a number, perhaps just not a 'positive' number.)
I did it the same way!!!
1 2 3 4 5 |
|
1 |
|
Same solution as above with list comprehension:
sum([1 for i in range(1, 1001) if '0' in str(i)])
One tenth of the integers from 1 to 1000 have a 0 as their last digit.
One tenth of the integers from 100 to 1000 have a 0 in their second digit.
The only number having a 0 in its third digit is already part of both other groups.
One tenth other the second group (0 in the second digit) is also part of the first group.
Thus there are: 1000/10 from the first group; 900/10 for the second group; (900/10)/10 for the overlap of the groups.
This makes 100 + 90 - 9 = 181
1 2 3 4 5 6 |
|
From all the 10s, 10, 20, 30 , 40, ... 1000 = 100 zeros. Only the first 10 numbers of each 100 i.e 101-109, 201-209, ... 901-909, there are 9 zeros in each column - 9*9 == 81 zeros. So this makes a total of 100 + 81 zeros = 181.
Numbers containing zeros have the following distinct forms and counts (x, y can be any non-zero digit):
X0..........9 possibilities
X0y........9*9=81 possibilities
Xy0........9*9=81 possibilities
X00........9 possibilities
1000......1 possibility
Since x and y are non-zero, there are no numbers that are double-counted.
9+81+81+9+1=181
Supposed we want to find the number doesn't contain 0 , three digits number will be 7 2 9 , two digits number will be 8 1 , and single-digit will be 9 . Thus, there are 1 0 0 0 − 7 2 9 − 8 1 − 9 = 1 8 1 numbers contain 0 .
Isn't there a pattern exist, is it ? 1 0 0 0 − 9 3 − 9 2 − 9 = 1 8 1 .
Log in to reply
Yeah, I noticed it but just write it other way.
There are 10 from one to 100. 9 from 200-300 9 from 300-400 9 from 400 to 500 and 9 for everything else. Ad them up, you get 181
Please modifiy: there 10+9 from 200-300 etc.
If you look at 0s in the 1s place that happens, in a set of numbers from 1-100 or 901-1000 (example 950), 10 times. That happens 10 times between 1-1000 so 10 times 10 equals 100 numbers.
Then there is 0s in the 10s place. That happens 9 times in a set of numbers from 101-200 (not including ones with 0s in the 1s place) and that only happens 9 times between 1-1000 because it doesn't happen between 1-99 as it needs 3 digits to have a 0 in the 10s place so 9 times 9 equals 81.
100+81=181 =>QED
From 1 to 100 only multiples of 10 has zeros (10, 20, 30, ...). From 1 to 1000 there are 10 times such series (10, 20, ..., 110, 120, ..., 210, 220, ...): 1 0 ∗ 1 0 = 1 0 0 .
Plus from 100 on, the first 9 numbers will also get a zero (101, 102, 103, ..., 109). From 100 to 1000 there are 9 such series (101, 102, ..., 201, 202, ..., 301, 302, ...): 9 ∗ 9 = 8 1 .
The total number of zeros is the sum of these: 1 0 0 + 8 1 = 1 8 1
In the first 100 there is 10, 20, 30 etc up to 100 which makes 10. From 100-200, there is 101, 102, 103 etc up to 110. Then there is 120, 130 etc up to 200. That makes 19. Each hundred after this follows the exact same number since the only thing that changes is the first digit. So that makes 9 sets of 19 + the 10 from 1-100. That makes 181. It does say the first 1000 positive integers so I thought it would include 1000 but it doesn't otherwise the answer would be 182.
The required number can be of the form(here [RN] means a random number that can be 1,2,3,4,5,6,7,8,9)
(1)[RN]0 In this [RN] can have 9 values hence their are 9 such numbers (2)[RN][RN]0 in this each [RN] can have 9 values hence total=9×9=81 (3)[RN]0[RN] in this again each [RN] can have 9 values total=9×9=81 (4)[RN]00 in this[RN] can have 9 values hence their are 9 such numbers (5)1000 their is only 1 such number TOTAL=9+81+9+81+1=181
Sorry if this is a repeat of any other previous solution, I just want to share how I came to a solution :-)
Integers | # of Zeros | comment |
1 - 10 | 1 | only integer 10 contains a zero |
1 - 100 | 10 | every 10'th contains a zero |
1 - 200 | 20+9 | every 10'th contains a zero, plus 101-109 |
1 - 300 | 30+9+9 | every 10'th contains a zero, plus 101-109 plus 201-209 |
1 - 400 | 40+9+9+9 | every 10'th contains as a zero, plus 101-109 plus 201-209 plus 301-309 |
1 - 500 | 50+9+9+9+9 | every 10'th contains a zero, plus 101-109 plus 201-209 plus 301-309 plus 401-409 |
1 - n | n being any positive integer evenly divisible with 100 |
the above implies that the number of integers containing at least one zero could be generalised to
1 0 n + 9 × ( 1 0 0 n -1)
So for n = 1000
1 0 1 0 0 0 + 9 × ( 1 0 0 1 0 0 0 - 1) = 100 + 9 × (10 - 1) = 100 + 81 = 181
1 |
|
I'm having a little trouble understanding this although I arrived to the same conclusion, only with a slightly different method. Now, from positive integers to a 1000 exclude zero itself and include 1000 itself, so you have 1 digit numbers, 2 digit numbers, 3 digit numbers, and a 4 digit number.
_ - 1 digit numbers: 9 of them don't have a zero: 9^1 = 9 numbers
_ _ - 2 digit numbers: on "ones", 9 numbers don't have a zero, and on "tens" 9 numbers don't have a zero: 9^2 = 81 numbers
_ _ _ - 3 digit numbers: on "ones", 9 numbers don't have a zero, on "tens" 9 numbers don't have a zero, and on "hundreds" 9 numbers don't have a zero: 9^3 = 729
Now 9+81+729 = 819 numbers don't have a zero, meaning that 999-819 = 180 do have a zero. And if we add the "1000", that makes it 181 numbers that have a zero. BUT wouldn't this mean that that includes zeros in places of "hundreds" in three digit numbers (9 of them), and zeros in places of "tens" in two digit numbers (also 9 of them)? That is: shouldn't it be 181-18 = 163?
Between 1 - 100 } 10 no.s
Between 100 - 200 } 10 + 9 no.s (Numbers in the form of x 0 y )
Between 200 - 300 } 19 no.s (( Same rule applies ))
Between 300 - 1000 } 19 × 7
∴ between 1 - 1000 = 10 + 19 + 19 + (19 × 7) = 1 8 1
Any multiple of 10 has a 0. There are 100 "10s" in a 1000.
101 has 0 in it too. So we need to include all solutions like 101.
The number 101 is of the form a0b where a and b are digits.
We know b can't be 0 because we already did that and a can't be 0 because that doesn't make sense.
Thus a is 1-9 and b is 1-9. We know 9x9 = 81.
100 + 81 = 181.
1 2 3 4 5 6 7 8 9 10 11 |
|
or just in linux command line: seq 1 1000 | grep 0 | wc -l
Its 100 // coz 10,20,30,.... //+81 // a01a02a03...a09 for all a belongs N 1-9 //
Problem Loading...
Note Loading...
Set Loading...
1 0 , 2 0 , 3 0 , 4 0 , 5 0 , 6 0 , 7 0 , 8 0 , 9 0 , 1 0 0
1 0 1 , 1 0 2 , 1 0 3 , 1 0 4 , 1 0 5 , 1 0 6 , 1 0 7 , 1 0 8 , 1 0 9 , 1 1 0 , 1 2 0 , 1 3 0 , 1 4 0 , 1 5 0 , 1 6 0 , 1 7 0 , 1 8 0 , 1 9 0 , 2 0 0
Total number of numbers with 0 as a digit = 1 0 + 9 ( 1 9 )
⟹ 1 0 + 1 7 1 = 1 8 1