[Math] Number of seven digit numbers without repetition of digits divisible by $3$

algebra-precalculuscombinatoricspermutationssequences-and-series

Find number of seven digit numbers divisible by $3$ with

$1.$ Repetition

$2.$ Without Repetition

For Part $1.$ The least seven digit number divisible by $3$ is $1000002$ and highest seven digit number is $9999999$

So total is $3000000$

For Part $2$ The least such number is $1023456$ and the next is $1023459$

Now sum of the digits of $1023456$ is $21$.

So if we include $7$ by removing one of the digits in $1023456$ then the digits that can be removed is $1$ or $4$.

If we include $8$ then digits that can be removed is $2$ or $5$.

but we get more cases here, any better way to approach?

Best Answer

Let $N_7 = \text{what you are looking for}$

However, this consists of one set that doesn't use any zeros - $(NZ)_7$ - and another that does. The number in the set that uses zeros can be defined recursively as $6(NZ)_6$ because the zero can be placed in 6 different places.

Notice that $(NZ)_7 = \frac{\text{pair of two numbers that are divisible by 3}}{9c2} \cdot(9\cdot8\cdot7\cdot6\cdot5\cdot4\cdot3)$

This is because the total sum of $1,2, ..8, 9$ is $45$ and we need to remove two numbers such that the sum of the others is still a multiple fo $3$ ie the two numbers we remove must be a multiple of $3$

Therefore, $(NZ)_7 = \frac{(NZ)_2}{9P2}(9\cdot8\cdot7\cdot6\cdot5\cdot4\cdot3)$

Similarly, $(NZ)_6 = \frac{(NZ)_3}{9P3}(9\cdot8\cdot7\cdot6\cdot5\cdot4)$

$(NZ)_2$ can be counted, but also it can be expressed as $9\cdot3 - \frac{1}{9}\cdot 9 \cdot 3$. This is found because if the first is $0 \mod 3$, then there is an overcounting (1/3 of such cases are false $1/3 *1/3 = 1/9$)

Similarly, $(NZ)_2=9\cdot 8 \cdot 3 - \frac{2}{8} \cdot \frac{2}{3} \cdot 9 \cdot 8\cdot 3$. Here, the second part is found by considering the probability that the second number chosen is the same modulus as the first ( $2/8$), which results in only $1/3$ of the possible last digits (so we subtract out $2/3$)

Therefore,

$$N_7 = \frac{9 \cdot 3 - 3}{72}(9\cdot8\cdot7\cdot6\cdot5\cdot4\cdot3) + 6 \cdot \frac{9\cdot8\cdot3-4\cdot9}{504}(9\cdot8\cdot7\cdot6\cdot5\cdot4) = 190080$$

This is definitely not my most eloquent answer, so please ask me questions if something is confusing, and I'll try to explain my thought process.