What are all the 3 digit combinations of 21 using 1 - 10?
Working on a project and I'm pretty sure I'm missing several combinations.
P.s. 5,7,9 is the same as 5,9,7 so I don't need both.
Sorry, I've been looking at the problem for so long I forgot to explain what I was asking for.
I'm looking for 3 number combinations with the sum of 21( for example 5+9+7 ) using the numbers 1 - 10.
- Andy JLv 79 years agoFavorite Answer
Can you explain what you mean a little better? The way you've presented it is confusing. Are you asking for triples (i.e. three number) each in the range 1-10 inclusive that sum to 21? If so, then don't use the word "digit" as that implies 0-9, not 1-10. Also, you said "combinations" and never mentioned "addition" or "sum" to indicate what is to be done with the numbers, leaving me to guess.
EDIT: OK, I'm assuming you can use the same number more than once, such as 7-7-7. The easiest way to do this is to use a logical sequence. Do it kind of like counting, where the first number starts low and increases. For example, start with 1-x-y. We know x + y = 20, so both x and y are 10. There are no more possible combinations starting with 1, so we move on to 2, and so on. We also limit ourselves to only increasing numbers among the 3 to eliminate duplicates. Thus, we don't consider 5-9-7 valid as that will be counted as 5-7-9.
That has to be the last one, because if we increase the first digit to 8, one of the others has to be less than 7.