Do you meant generate possible combination of sum of numbers?
Start with an empty set s = {0}
For each number a,b,c
:
duplicate the existing set s
, add each number to the duplicated set. Add the results back to s
.
Example:
s = {0}
for a:
duplicate s, s' = {0}
add a to each of s', s' = {a}
add s' back to s, s = {0,a}
for b:
duplicate s, s' = {0,a}
add b to each of s' = {b,a+b}
add s' back to s, s= {0,a,b,a+b}
for c:
dupicate s, s' = {0,a,b,a+b}
add c to each of s' = {c,a+c,b+c,a+b+c}
add s' to s, s = {0,a,b,a+b,c,a+c,b+c,a+b+c}