I have a problem that is about addition combinations of numbers.
For example, i have a function which takes 2 integer parameters to find all addition combinations of given parameter.
To illustrate:
public List<List<int>> getcombinations(int numbercount, int target){
....
return List;
}
Let's determine the arguments by making up:
numbercount=3 //it will be calculated with 3 integers
target=9 // final number to find
The output of the function is supposed to be in this way:
{{1,1,7},{1,2,6},{1,3,5},{1,4,4},{2,2,5},{2,3,4},{3,3,3}}
Our target number can be found with 7 possibilities when 3 integers is used in addition.
One more example:
numbercount=2
target=7
//Output should be like this:
{{1,6},{2,5},{3,4}} // 3 possibilities when 2 integers is used in addition.
I tried to find a solution for this problem. But I could not find a way to solve it. What do you advise to search or learn about to solve it?