How many positive integers less than 10,000 are there in which sum of digits equals 5?
We know that a number less than 10,000 contains up to 4 digits that must sum to 5.
The combinations that sum to 5:
5,0
4,1
3,2
3,1,1
2,2,1
2,1,1,1
This creates anagrams for the 4-digits of the integers as follows:
5000, 0500, 0050, 0005 can be represented by AXXX = 4C1 = 4C4 = 4!/3! = 4
4100, 1400, 4010, etc.. ABXX = 4!/2! = 12
3200, 2300, etc.. ABXX = 4!/2! = 12
3110, 1310, etc.. ABXX = 4!/2! = 12
2210, 2120, etc.. ABXX = 4!/2! = 12
2111, 1211, etc.. AXXX = 4!/3! = 4
12*4 + 4*2 = 48 + 8 = 56 integers whose digits sum to 5.
How many positive integers less than 10,000 are there in which sum of digits equals 3?
The combinations that sum to 3:
3,0
2,1
1,1,1
This creates anagrams for the 4-digits of the integers as follows:
3000, 0300, etc.. AXXX = 4!/3! = 4
2100, 2010, etc.. ABXX = 4!/2! = 12
1110, 1011, etc.. AXXX = 4!/3! = 4
12*1 + 4*2 = 12 + 8 = 20 integers whose digits sum to 3.
Using Mitch's separator method:
DDD||| for 3,0,0,0
DD|D|| for 2,1,0,0
D|D|D| for 1,1,1,0
We compute the anagram for |||DDD
6C3 = 6!/(3!3!) = 6*5*4 / 3*2 = 5*4 = 20