Thursday, December 17, 2009

How many five-digit numbers are there whose digits sum to 39?

How many five-digit numbers are there whose digits sum to 39?





For example, 87654 sum to 8+7+6+5+4 = 30





Please help, many thanks!How many five-digit numbers are there whose digits sum to 39?
There might be a shortcut or something, but (perhaps) unlucky for you I'm not a shortcut kind of guy. I won't say that I am 100% correct, but I know that this can be solved by this ';bootstrapping'; method.





9 * 4 = 36, thus





9*4 + 0, 9*4 + 1, 9*4 + 2





all fall short of 39. Therefore, such a number will not have a 0, 1, or 2 in it.





If it has a 3, then the rest of the digits must add to 36, and must all be 9's. There are five such numbers (choose where to put the three): 39999, 93999, 99399, 99939, 99993.





If it has a 4, then the rest add to 35, and the only way to get that is with three 9's and an 8. So choose the slot to put the 4, then the slot for the 8 out of the remaining 4. Total: 5*4 = 20.





If it has a 5, then the rest add to 34. This can happen in one of two ways: one 7 and three 9's, or two 9's and two 8's.


Total: 5 * 4 + 5 * 4C2 (%26lt;-choose two spots out of the remaining four to put the 8's) = 20 + 30 = 50.





If it has a 6, then the rest add to 33.


If it has three 9's then the other digit is also a 6. Total: 5C2 = 10.


If it has two 9's then the other two digits add to 39-6-9-9 = 15, and must be 7 and 8 (can't be any more 9's). Total: 5*4*3 = 60.


If it has only one 9, then the remaining three add to 39-6-9=24, and must be all 8's. Total: 5*4 = 20.


Such a number must have at least one 9, as 8*4 + 6 %26lt; 39.





Running total thusfar:165, with more to come.





All that remains are numbers where all digits are at least 7.


7*5 = 35, so we need to add 4 into the digits. We can do this in one of three ways:





- Add 1 to four of the digits. The number will have a 7, with the rest 8's (e.g 88788). There are five such numbers.


- Add 1 to two of the digits, and two to one digit. This number will have two 7s, two 8s, and a 9. There are 5*4C2 = 30 such numbers.


- Add 2 to two of the digits. Number will have three 7s and two 9s. there are 5C2 = 10 such numbers.


-There are no other possibilities, as we cannot add more than 2 to 7.





So I have a total of





165 + 45 = 210





such numbers.





Hope this helps.

No comments:

Post a Comment