How many different 7 digit natural numbers with no 0 anywhere don't contain 454 as a string of three consecutive numbers anywhere?
I think this involves inclusion/exclusion, but i'm not sure where to go with it. I know it would start with $9^7$- ...
How many different 7 digit natural numbers with no 0 anywhere don't contain 454 as a string of three consecutive numbers anywhere?
I think this involves inclusion/exclusion, but i'm not sure where to go with it. I know it would start with $9^7$- ...
The answer can be seen if you construct a chart of your possibilities. You are right that the total number of seven digit numbers without 0 is $9^7$. The chart below gives possible positions of our string and excludes possibilities already considered (top to bottom).
\begin{array}{ccc} 1&2&3&4&5&6&7\\ 4&5&4&&&& &9^4\\ &4&5&4&&& &9^4\\ &&4&5&4&& &9^4 - 9^2\\ &&&4&5&4& &9^4-9^2-9\\ &&&&4&5&4 &9^4-9^2-9-9\\ \end{array}
Thus, we find that we have $9^7-(5(9^4) - 3(9^2)-3(9)) = 4750434$ possibilities.
Let $E$ be the set of all $7$-digit strings with no $0$s. Let $A_i$ be the set of all strings in $E$ which contain a $454$ starting with the $i^{\text{th}}$ digit; so $A_1$ contains strings of the form $454????\ $, $A_2$ contains strings of the form $?454???,\ $ $A_3$ contains strings of the form $??454??,$ and so on. I will use the in-and-out formula to find $|E\setminus(A_1\cup A_2\cup A_3\cup A_4\cup A_5)|.$ To save typing I will write intersections as $A_1A_2$ instead of $A_1\cap A_2.$
$|E|=9^7.$
$|A_1|=|A_2|=|A_3|=|A_4|=|A_5|=9^4.$
$|A_1A_2|=|A_2A_3|=|A_3A_4|=|A_4A_5|=0.$
$|A_1A_3|=|A_2A_4|=|A_3A_5|=9^2.$
$|A_1A_4|=|A_2A_5|=|A_1A_5|=9^1.$
$|A_1A_3A_5|=1.$
$|E\setminus(A_1\cup A_2\cup A_3\cup A_4\cup A_5)|$
$=|E|-|A_1|-|A_2|-|A_3|-|A_4|-|A_5|$ $+|A_1A_3|+|A_2A_4|+|A_3A_5|+|A_1A_4|+|A_2A_5|+|A_1A_5|-|A_1A_3A_5|$
$=9^7-5\cdot9^4+3\cdot9^2+3\cdot9^1-1=\boxed{4750433}.$