Hi everyone, first time on this forum and I'm thrilled. I was wondering if anyone could perhaps show me where I can find an article, formula, book, etc, that tells me what I want to find below.

You have a number n and a list of numbers. I want to generate all the different combinations from the list that add up the n.

Example.

n = 4;

list = [1,2]

Combination 1: 1 + 1 + 1 + 1 = 4

Combination 2: 1 + 1 + 2 = 4

Combination 3: 2 + 2 = 4

There are 3 different combinations that sum up to 4 from the given list.

n = 6

list = [1,3,6]

Combination 1: 1+1+1+1+1+1 = 6

Combination 2: 1+1+1+3 = 6

Combination 3: 3+3 = 6

Combination 4: 6=6

There are 4 different combinations that sum up to 6 from the given list.

Is there an algorithm or something that I can use in a java program that will accomplish this?

Thank you.