[Math] How many k-digit numbers ending with zero(s) are there

combinatorics

We have a $k$-digit non-negative number in base $B$ (let's treat all k-digit numbers as valid, so that for example if $k=5$ and base $10$ all numbers from $00000$ to $99999$ are perfectly fine).

How many numbers are there that end with one or more $0$?

The answer is $B^{k-1}-1$, but I can't really figure out why.

Best Answer

Let's first solve it for arbitrary sequences of with values in $\{0,\dots,B-1\}$. Then clearly there is a bijection between sequences of length $k$ ending in $0$ and sequences of length $k-1$, and we know there are $B^{k-1}$ instances of the latter. Now you want only sequences denoting non-negative numbers, so $0^k$ is no longer an option, but that's the only sequence that you forbid, so the answer is $B^{k-1}-1$.

Edit: @mvw is right, I mistook non-negative for positive. So if you really mean non-negative, I can't explain the answer either.