Yes, that Idea is very good. So we have to count the six digit numbers which have sum of digits more than $47$. Notice if each digit is $9$ then the sum of digits is $54$, to make it $48$ we would have to subtract one from some digits $6$ times. To make it $49$ we would have to subtract one from some digits $5$ times etc.
So how many ways are there to subtract one from some of the $6$ positions $6$ times? This is equal to the number of ways to add to $6$ using non-negative integers $a_1+a_2+a_3+a_4+a_5+a_6=45$.
Because $6\leq 9$ we can solve this easily using stars and bars ( notice we need $6\leq 9$ because otherwise some combinations would be weird, like subtracting $10$ from digit $1$ for example , as this would make digit $1$ be $-1$).
We try to solve it by stars and bars, there are going to be $6-1=5$ bars and $6$ stars. So there are $\binom{6+5}{5}$ ways to do it.
Using the same reasoning there are $\binom{5+5}{5}$ ways to substract $5$ times, $\binom{4+5}{5}$ ways to subtract $4$ times and so on.
So the final answer is $\sum_{i=0}^6\binom{i+5}{5}$, we don't have to do this sum, this sort of sum is fairly common, and via the hockey stick identity is equal to $\binom{5+7}{6}=924$. Thus final answer is $900000-924=899076$.
The following c++ code verifies this:
#include <cstdio>
int sumd(int a){
int b=0;
while(a!=0){
b+=a%10;
a/=10;
}
return(b);
}
int main(){
int a,b=0;
for(a=100000;a<1000000;a++){
if(sumd(a)<=47){
b++;
}
}
printf("%d\n",b);
}
The hints in the comment section provides valuable insights to the problem.
I will write a complete answer just to be sure you understand the hints.
There are $3$ cases whereby the sum of the $4$ digits is even,
(1) All $4$ digits are odd.
(2) All $4$ digits are even.
(3) $2$ digits are odd and $2$ digits are even.
First, note that there are $4$ odd digits and $3$ even digits in the set $\{1,2,3,4,5,6,7\}$.
Let's start with Case (1).
Since each digit can only be chosen once, there is $4$ ways of choosing the first odd digit from $\{1,3,5,7\}$,
followed by $3$ ways of choosing the second odd digit from the remaining $3$ digits,
followed by $2$ ways of choosing the third odd digit from the remaining $2$ digits,
followed by $1$ way of choosing the forth odd digit from the remaining $1$ digit.
So, there are $4\times 3 \times 2\times 1 = 4!$ possibilities for Case (1).
Now on to Case (2),
there are $3$ even digits in $\{1,2,3,4,5,6,7\}$, namely $2,4,6$.
Remember that the $4$ digit number must contain different digits, we cannot use either $2$, $4$ or $6$ more than once to construct the $4$ digit number.
And furthermore, there are only $3$ even digits available, so it is impossible to construct any $4$ digit number with no repetition of a digit.
Hence, there is $0$ possibilities for Case (2).
Finally, let's move on to Case (3), which is slightly more difficult.
We first do an unordered selection of $2$ odd digits from $\{1,3,5,7\}$.
which gives $\binom{4}{2}$ possibilities,
followed by an unordered selection of $2$ even digits from $\{2,4,6\}$.
which gives $\binom{3}{2}$ possibilities.
An example would be choosing the digits $1, 5, 2, 4$.
We can quickly see that a valid $4$ digit number would be $1524$.
Note that other permutations of the $4$ digits also form a valid $4$ digit number,
example, $5124$ and $1542$.
and, there are $4!$ permutations in total.
So, by the product rule, there are $\binom{4}{2} \times \binom{3}{2} \times 4!$ possibilities.
Finally, by sum rule, there are a total $4! + 0 +\binom{4}{2} \times \binom{3}{2} \times 4!$ possibilities for the $3$ mutually exclusive cases.
Best Answer
Using the multiplication rule we get total number of 7 digit numbers as $9*9*8*7*6*5*4=544320$
The reasoning for this can be given as : For the first digit of the number we can select any of the nine of the nine digits from 1 to 9, for the second digit we can select any digit from 0 to 9 excluding the one which we have already placed in the first position . For the third place we have 8 options to choose from 0 to 9 excluding the digits we already placed on first and second positions. Hence the answer appears.
Also there will be $6*6*5*4*3*2*1=4320$ seven digit numbers having the digits $0,1,2,3,4,5,6$ giving minimum sum as 21. The reasoning is same as above.