×   Home   Blog   Newsletter   Privacy   Contact Us   About

Containing a one

Imagine all the positive integers in the range 1-1,000,000,000 (inclusive).
How many of these numbers contain the digit ‘1’ in some location?
For example 43,252,003 does not, but 980,107 and 98,111,787 do. Take a guess before thinking about it.

Solution

To find out how many contain, at-least, one occurrence of ‘1’, we can work out the complement; how many contain no occurrences and subtract this from the total. If we consider that every positive number less than 1,000,000,000 is a nine digit number (prepending zeros, as necessary, to pad it out), then each of these digits can be one of the nine possible digits in the set [0,2,3,4,5,6,7,8,9] so there are 99 combinations. However, there is a special case when every single digit is zero, and this is not valid, so we need to subtract for this case, so the answer is 99-1 = 387,420,488
This means that the number that do contain the digit ‘1’ is 1,000,000,000-387,420,488=612,579,512 which as a percentage is ≈ 61.258%
This is a higher percentage than my initial gut feel!
The percentage of the first billion numbers that contain the digit ‘1’ ≈ 61.258%
Advertisement:

Bigger Numbers

What happens if we use a different number? 1,000,000,000 = 109, let’s look at how things change for 10n
n9n - 110nPercentage
 181020.000%
 28010020.000%
 37281,00027.200%
 46,56010,00034.400%
 559,048100,00040.952%
 6531,4401,000,00046.856%
 74,782,96810,000,00052.170%
 843,046,720100,000,00056.953%
 9387,420,4881,000,000,00061.258%
 103,486,784,40010,000,000,00065.132%
 1131,381,059,608100,000,000,00068.619%
 12282,429,536,4801,000,000,000,00071.757%
 25717,897,987,691,852,588,770,24810,000,000,000,000,000,000,000,00092.821%
 50950-11E+5099.485%
 1009100-11E+10099.997%
As n gets larger:
We can see that, as the size of the number gets bigger, a higher, and higher concentration of the numbers contain the digit ‘1’ (or any other digit).
At primary school, we used to play a game called “Buzz”, where we would go around the classroom incrementing numbers 1, 2, 3 … but there would be a magic number of the day (say “5”), and instead of saying a number that contained that digit, you would say “Buzz”.

1, 2, 3, 4, Buzz, 6, 7, 8, 9, 10, 11, 12, 13, 14, Buzz, 16, 17 …

You can see that if you played this game for a loooong time, it would become very boring.