Stupid numbers game Occasionally I encounter a recurring instance of stupidity when I teach mathematics, namely that someone asks if we can play a game known in Danish under the name "bum", since that person thinks that that game has something relevant to do with mathematics.
The game goes as follows

You have to decide on a decimal digit $a$. Then people in the room count through the natural numbers taking turns, each person shouting out one number then passing on to the next person. But whenever the number to shout is divisible by $a$ or has the digit $a$ somewhere in it, that person shouts "bum" instead.

Today I answered to the suggestion of playing that game using $a=7$ by saying, that I found the game of no mathematical relevance. But if we were to make anything mathematically interesting of it, we should instead find out how many times the word "bum" is shouted in a flawless "bum"-game running from $1$ through $10^6$.
I estimated this figure as $10^6-9^6\cdot \frac 67=544479.\overline{142857}$. Later I wrote a code snippet working out the exact answer as $544480$.
Question
Is there a nice way to derive the figure $544480$ mathematically without writing a program?
 A: You have $6$ digits, each of which must be in $[0,9]\setminus\{7\}$. The remainders modulo $7$ of the digit values $10^k$ for $k\in[0,5]$ are $1,3,2,6,4,5$, respectively, which are all invertible in $\mathbb Z_7$. Group the admissible digits as $[0,6]\cup\{8,9\}$. If any of the digits is in $[0,6]$, as the first such digit varies across $[0,6]$ the remainder of the number modulo $7$ also varies across $[0,6]$, so exactly $1/7$ of such numbers are bummers. That leaves only the $2^6=64$ numbers consisting only of $8$s and $9$s, equivalent to $1$s and $2$s. Since the sum of the digit values is a multiple of $7$, this is equivalent to $0$ and $1$s. So the remaining question is how many subsets of $[1,6]$ add up to $0$ modulo $7$. We don't have to test all $64$ since a subset adds up to $0$ if and only if its complement does. The subsets with less than $3$ elements are easy to find: only $\{\}$, $\{1,6\}$, $\{2,5\}$, $\{3,4\}$ add up to $0$. Of the ones with $3$ elements, we only need to check the ones containing $1$, and a moment's reflection shows that of these, only $\{1,2,4\}$ qualifies. That yields a total of $2(1+3+1)=10$ out of $64$ subsets that add up to $0$, so the total number of bummers is $10^6-\frac67(9^6-64)-64+10=544480$.
This also throws some light on why your estimate was so good – it was only the extra $64$ numbers for which your estimate $64/7\simeq9.1$ was off by about $1$.
