×   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.


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%

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
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.