How many numbers are between 1 and 99999 which have the sum of their digits equal to 15? I need the method.

1 Answer
Feb 18, 2018

#2826#

Explanation:

Let us write #d(n, k)# for the number of ways of distributing #n# identical objects amongst #k# slots, with at most #9# objects in a slot.

If #n <= 9# then this is a "stars and bars" calculation:

#d(n, k) = ""^(n+k-1) C_(k-1)" "# if #n <= 9#

With the constraint that at most #9# objects are allocated to each slot, we can adjust the "stars and bars" figure by subtracting the ways of distributing the remaining objects when one of the slots contains more than #9# objects.

Then:

#d(15, 5) = ""^(15+5-1) C_(5-1) - 5(sum_(j=1)^6 d(j, 4))#

#color(white)(d(15, 5)) = ""^19C_4 - 5(""^4C_3 + ""^5C_3 + ""^6C_3 + ""^7C_3 + ""^8C_3 + ""^9C_3)#

#color(white)(d(15, 5)) = 3876 - 5(4 + 10 + 20 + 35 + 56 + 85)#

#color(white)(d(15, 5)) = 3876 - 5(210) = 3876 - 1050 = 2826#