5

How many integers from $43523$ to $93107$ contain the digit $7$ at least once?

I know that if we had $43000$ to $93000$, we would subtract integers that do not contain digit $7$ from the total number: $50000 - (5\times9\times 9\times 9 \times 9)$

But how to do it with the given numbers?

Roby5
  • 4,287
ReeSSult
  • 409

1 Answers1

7

First idea: if you want the number of something from $42523$ through $93107$, it may be easier to count the ones from $0$ through $93107$ and subtract the ones from $0$ through $42522$. Let $N(n)$ be the number of numbers up to $n$ that contain at least one $7$. You want $N(93107)-N(43522)$. It helps to prefix the numbers with zero so all numbers have five digits. Second idea: $N(93107)$ consists of all the numbers that start with $7$, which is $70000$ through $79999$, plus all the others that contain at least one $7$. For the ones that start with $0$ through $8$, that is $8$ times as many as the four digit numbers that contain at least one $7$. This suggests a recursive algorithm. I leave the problem that you only want some of the numbers that start with $9$ to you. The idea is the same.

InsideOut
  • 6,883
Ross Millikan
  • 374,822