all combinations of a set of numbers that sum up to a specific value

128 Views Asked by At

Is there a systematic way to find all the combinations of a set of numbers that sum up to a specific value?

For example, I have the numbers $36, 27, 12, 6, 4$, and $2$. I want all sets of these numbers that sum up to $39$. Clearly, $36$ can be removed from the problem, but that doesn't happen in general.

I can find {$27,12$} and {$27,6,4,2$} by inspection and think that may be it. But is there a way to quickly find all of these sets for a large problem?