How many $5$-digit numbers with distinct digits are divisible by 3 (and generalize)
The set $S$ of five digit numbers with distinct digits has $27\,216$ elements. Write $S=S'\cup S_0$, whereby $S'$ consists of the numbers $n\in S$ without a $0$ in their decimal expansion, and $S_0$ consists of the numbers $n\in S$ with exactly one $0$ in their decimal expansion. I claim that exactly one third of the numbers in $S$, meaning $9072$, are divisible by $3$.
Proof. Consider the following bijective map $f:\>S\to S$: Given a number $n\in S$, apply the map $$1\mapsto2\mapsto3\mapsto4\mapsto5\mapsto6\mapsto7\mapsto8\mapsto9\mapsto1\>, \qquad 0\mapsto0$$ to its digits. Examples: $f(42937)=53148$, $f(31304)=42405$.
The map $f$ is bijective. Furthermore $f$ adds $2$ mod $3$ to numbers in $S'$, and $1$ mod $3$ to numbers in $S_0$. Now both $S'$ and $S_0$ consist of three parts according to the remainder of $n$ modulo $3$, and $f$ permutes the three parts of $S'$ as well as the three parts of $S_0$. It follows that exactly one third of the numbers in $S'$ and one third of the numbers in $S_0$ is divisible by $3$.
First calculate four-digit numbers with no zeros that are divisible by 3. These are the five-digit numbers that start wlwith 0.
If there are no digits from $A=\{3,6,9\}$ there must be two each from $B=\{1,4,7\}$ and $C=\{2,5,8\}$ so that the sum is a multiple of $3$. Three ways to pick from $\{1,4,7\}$ and three from $\{2,5,8\}$, or nine in all.
If there is one digit from $\{3,6,9\}$, then you need all of $B$ or all of $C$, six possibilities in all.
I think there are $42$ possibilities altogether, which can each be arranged in $24$ ways, to give $1008$ four-digit multiples of $3$ with no zeroes and no repeated digits.
Do the same thing for five-digit numbers.