1

If $2$ numbers $n$ and $m$ are given, how can be found out the number of numbers with zero between and including $m$ and $n$ ($m \leq n$)?. For example, if $m=10$, $n=100$ the numbers with zeroes are $10,20,30,40,50,60,70,80,90,100$ .i.e 10 numbers.

My question is that there is any recursive formula to calculate the number of numbers with zero in a given range. If so, what is that? And what is the reasoning behind it? Please explain it clearly.

ajotatxe
  • 65,084
  • 3
    What is a "number with zero"? One that ends on a $0$ symbol or one that has at least one $0$ symbol in its decimal representation? E.g. is $101$ a number with zero in your sense? – mvw Oct 20 '14 at 14:33

1 Answers1

1

Hint: the number of numbers that are multiples of $10$ and less than or equal to $n$ is $\lfloor \frac n{10}\rfloor$ Now subtract the ones that are strictly less than $m$ and you are home.

If you want to include interior zeros, again it is easier to count the number from $1$ through $n$ and subtract the number from $1$ through $m-1$. Call this $N(n)$. How many numbers from $10^{k-1}$ through $10^k-1$ have no zeros? You have $k$ digits, each of which has $9$ choices, so there are $9^k$ of them. That leaves $10^k-10^{k-1}-9^k=9\cdot 10^{k-1}-9^k=9(10^{k-1}-9^{k-1})$. Now if $n=a10^k+b$, where $b \lt 10^k$, you have $N(n)=9a(10^{k-1}-9^{k-1})+N(b)$

Ross Millikan
  • 374,822