Find all combinations that add up to a given number

This is called a knapsack problem.

Do you mind if I ask why you’re trying to do this in Grasshopper? I’m imagining some comp sci professor laughing as he gives an assignment like this: Grasshopper is great; it’s just not a language you’d typically use for a problem like this.

However, once you know what it is (knapsack problem), it’s been discussed:
Reach a variable number with the sum of fixed numbers - Grasshopper Developer - McNeel Forum

and you could google search
site:discourse.mcneel.com grasshopper “knapsack” problem