0
$\begingroup$

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$- ...

  • 0
    Yes, inclusion-exclusion would be the way to do it. unfortunately there's a bit of a zoo of cases to consider: `*454*`, `*45454*`, `4545454`, `*454*454*` along with how they interact.2017-02-26

2 Answers 2

2

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.

  • 0
    I'm confused by the right side of the chart, where does the $9^4$ come from2017-02-26
  • 0
    If you fix three digits, then you can vary the other digits $9^4$ different ways.2017-02-26
  • 0
    Ok I got it, and when you are subtracting the ones below it, is that just because you were counting them twice?2017-02-26
  • 0
    The reasoning looks sound to me. Good answer. Perhaps some elaboration on how you're avoiding the double counting could help though.2017-02-26
  • 0
    Ah, I see you've already started that in the comments. ^2017-02-26
  • 0
    I don't understand why the second row wouldn't be $9^4-9$2017-02-26
  • 0
    To avoid double counting, consider "Could the position of my string be located in any of the numbers above?"2017-02-26
  • 0
    We have not yet considered a number with a 4 in the second position.2017-02-26
  • 0
    Ok I think I got it, it's just confusing to see that in this method2017-02-26
0

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}.$