Use recursion ...
The sets of 5 numbers (1 to 9) that add up to 28 include:
: the number 1 plus the sets of 4 numbers (2 to 9) that add up to 27
: the number 2 plus the sets of 4 numbers (3 to 9) that add up to 26
...
: the number 5 plus the sets of 4 numbers (6 to 9) that add up to 22
...
Note that I've made the numbers "go" into sets in ascending order; this way there is no repetition in the recursive calls.