Learning Scientific Programming with Python (2nd edition)
P6.5.4: Finding the number of integers not containing the digit 5
Question P6.5.4
Let the column matrix $$ \mathbf{F_n} = \left( \begin{array}{l}p_n \\ q_n\end{array} \right) $$ describe the number of non-negative integers less than $10^n$ ($n \ge 0$) that do ($p_n$) and do not ($q_n$) contain the digit 5. Hence, for $n=1$, $p_1=1$ and $q_1=9$. Devise a matrix-based recursion relation for finding $\mathbf{F_{n+1}}$ from $\mathbf{F_n}$.
How many numbers less than $10^{10}$ contain the digit 5?
For each $n \le 10$, find $p_n$ and verify that $p_n = 10^n - 9^n$.