
4. Find the number of all 6-digit natural numbers such that the sum of their digits is 10 and each of the digits $0,1,2,3$ occurs at least once in them.


Solution: We observe that $0+1+2+3=6$. Hence the remaining two digits must account for for the sum 4 . This is possible with $4=0+4=1+3=2+2$. Thus we see that the digits in any such 6 -digit number must be from one of the collections: $\{0,1,2,3,0,4\},\{0,1,2,3,1,3\}$ or $\{0,1,2,3,2,2\}$.

Consider the case in which the digits are from the collection $\{0,1,2,3,0,4\}$. Here 0 occurs twice and the digits $1,2,3,4$ occur once each. But 0 cannot be the first digit. Hence the first digit must be one of $1,2,3,4$. Suppose we fix 1 as the first digit. Then the number of 6 -digit numbers in which the remaining 5 digits are $0,0,2,3,4$ is $5!/ 2!=60$. Same is the case with other digits: $2,3,4$. Thus the number of 6 -digit numbers in which the digits $0,1,2,3,0,4$ occur is $60 \times 4=240$.

Suppose the digits are from the collection $\{0,1,2,3,1,3\}$. The number of 6 -digit numbers beginning with 1 is $5!/ 2!=60$. The number of those beginning with 2 is $5!/(2!)(2!)=30$ and the number of those beginning with 3 is $5!/ 2!=60$. Thus the total number in this case is $60+30+60=150$. Alternately, we can also count it as follows: the number of 6 -digit numbers one can obtain from the collection $\{0,1,2,3,1,3\}$ with 0 also as a possible first digit is $6!/(2!)(2!)=180$; the number of 6 -digit numbers one can obtain from the collection $\{0,1,2,3,1,3\}$ in which 0 is the first digit is $5!/(2!)(2!)=30$. Thus the number of 6 -digit numbers formed by the collection $\{0,1,2,3,1,3\}$ such that no number has its first digit 0 is $180-30=150$. Finally look at the collection $\{0,1,2,3,2,2\}$. Here the number of of 6 -digit numbers in which 1 is the first digit is $5!/ 3!=20$; the number of those having 2 as the first digit is $5!/ 2!=60$; and the number of those having 3 as the first digit is $5!/ 3!=20$. Thus the number of admissible 6 -digit numbers here is $20+60+20=100$. This may also be obtained using the other method of counting: $6!/ 3!-5!/ 3!=120-20=100$.

Finally the total number of 6 -digit numbers in which each of the digits $0,1,2,3$ appears at least once is $240+150+100=490$.
