Having an array of integers (eg. 3, 4, 5), how can you find all combinations they can be added up to a given sum? (eg. 17)
For the example there would be four ways the three numbers can add up to 17:
- 5 + 5 + 4 + 3
- 5 + 4 + 4 + 4
- 5 + 3 + 3 + 3 + 3
- 4 + 4 + 3 + 3 + 3
How would you calculate this programmatically? Eg. using javascript.