I have these problems from Brilliant.org:
a) How many 7-digit positive integers are there, satisfying that it is divisible by 7 and each of its digits is 1, 2, 3, 4, 5, 6, or 7?
b) The same question as a), but digit 0 is also allowed.
For a) I got $7^6$ and I think I can prove it, but what I really like to get help or solution for b).
The answer to (a) is $7^6$ like you claim. This is because for every choice of the first $6$ digits of the number, there is exactly one units digit that will make the number divisible by $7$.
While typing the solution for part (b) that is at the bottom of this answer, I realised that there is a much simpler solution. I've kept the write-up, but will include the simpler solution here.
We reason in a similar way to part (a). There aree $8^6$ options for the last $6$ digits of the number. For each of these, there is exactly one choice for the first digit of the number that will make the number divisible by $7$. We only have one choice even when the final $6$ digits of the number form a multiple of $7$, because we exclude the possibility of leading zeros, and so in this case the leading digit must be a $7$.
Original solution for part (b):
Part (b) is slightly more complicated. Let $a_n$ be the number of $n$-digit numbers which are divisible by $7$ and which consist only of the digits from $0$ to $7$. Note that $a_1 = 1$. (We don't include $0$ as a one-digit number. This will give us the correct answer later because we don't want leading zeros.)
To find $a_{n+1}$, we again look at the first $n$ digits of the number, and then see how many choices there are for the last digit to make the number divisible by $7$. If the number formed by the first $n$ digits is divisible by $7$, then the last digit must be $0$ or $7$. For each of the $a_n$ possibilities for the first $n$ digits, there are thus $2$ options for the last digit.
On the other hand, suppose that the number formed by the first $n$ digits is not divisible by $7$. There is then $7 \cdot 8^{n - 1} - a_n$ options for the first $n$ digits. (The first $n$ digits can be any of the $7 \cdot 8^{n - 1}$ $n$-digit numbers without a leading zero, except for the $a_n$ of them that are divisible by $7$.) For each choice of the first $n$ digits, there is exactly one choice for the final digit that makes the whole number divisible by $7$, so we get an additional $7 \cdot 8^{n - 1}$ numbers is this case.
We find that $$ a_{n + 1} = 2 a_n + 7 \cdot 8^{n - 1} - a_n = a_n + 7 \cdot 8^{n - 1}. $$
We thus have that $$ a_n = a_{n - 1} + 7 \cdot 8^{n - 2} = a_{n - 2} + 7 \cdot 8^{n - 3} + 7 \cdot 8^{n - 2} = \dots = a_1 + 7 \cdot 8^0 + \dots + 7 \cdot 8^{n - 3} + 7 \cdot 8^{n - 2} = 1 + 7 \cdot \frac{8^{n - 1} - 1}{8 - 1} = 8^{n - 1}. $$
It follows that the answer for part (b) is $8^6$.