I would have preferred A/C's w/the Q.
Anyway the only pattern I see here is this:
For numbers 1-100:
we have 5, 15, 25, 35, 45, (50-59: ten of these), 65, 75, 85, 95
That's 9*(1) + 10 = 19
1-1000:
This can split into 10 groups of 100 each, and 9 of them behave the same way as the 1-100 shown above. The only exception then is 500-599 (100 of these)
Thats 9*(9*(1) + 10) + 100
Contunuing this pattern..
1-10K:
9*(groups of 1000 see above) + 1K
or 9*(9*(9*(1) + 10) + 100) + 1K
1-100K:
9*(9*(9*(9*(1) + 10) + 100) + 1K) + 10K
1-1000K or 1m:
9*(9*(9*(9*(9*(1) + 10) + 100) + 1K) + 10K) + 100K
So the probability for selecting a number that contains 5 as one of its digits is
[9*(9*(9*(9*(9*(1) + 10) + 100) + 1K) + 10K) + 100K]/1m
I only hope there's an easier way to this