K
Koen
Hi,
I am looking for an algorithm that figures out which numbers from a
given set add up to another number. I am sure this has been done
before, but I have no idea how such a calculation is called, which
kind of limits my further searching.
An example. The set contains the numbers 1-2-3-4-5. Now the algorithm
should calculate all possible combinations of these numbers that add
up to 10. Each number can be used more than one time or not at all.
possible solutions are:
10 x 1
5 x 2
3 x 2 + 4
1 + 4 + 5
2 + 3 + 5
1 + 2 + 3 + 4
etc.
In this case it's pretty easy to do it on paper, but when the numbers
become larger (>1000) it would be nice to have a program to do this.
Any suggestions how to do this and/or where to start looking ?
thanks,
- Koen.
I am looking for an algorithm that figures out which numbers from a
given set add up to another number. I am sure this has been done
before, but I have no idea how such a calculation is called, which
kind of limits my further searching.
An example. The set contains the numbers 1-2-3-4-5. Now the algorithm
should calculate all possible combinations of these numbers that add
up to 10. Each number can be used more than one time or not at all.
possible solutions are:
10 x 1
5 x 2
3 x 2 + 4
1 + 4 + 5
2 + 3 + 5
1 + 2 + 3 + 4
etc.
In this case it's pretty easy to do it on paper, but when the numbers
become larger (>1000) it would be nice to have a program to do this.
Any suggestions how to do this and/or where to start looking ?
thanks,
- Koen.