I need to find the number of total possible different solution to an equation with more than one variable.
For example:
$$ 1x + 2y + 8z = 13 $$
What is the total number of different combinations for the values of $x$, $y$ and $z$? I can't think of an algorithm to solve this. I don't need the answers printed, just the total number of different combinations! The coeficients will always be positive, so are the variables and the final number too.
$x, y ,z$, and possibly more are always positive integers (or $0$)!
Guys, the question above is not what I really wanted to ask, you can find it better formulated bellow. I tried to solve it with this code here, and it did not work, it returns 647 instead of the expected 415 for the inputs ({1,2,8}, 13):
public static int getProbability(int[] distances, int n){
if(n==distances[0])
return 1;
else if(n<distances[0])
return 0;
else {
int returnInt = 0;
for (int i=0 ;i<distances.length; i++){
returnInt += getProbability(distances, n-distances[i]);
}
if (Arrays.binarySearch(distances, n) != -1) {
returnInt = returnInt+1;
}
return returnInt;
}
}
The quesiton is: Given the length 13, and N possible movements (3 in this case, movements of length 1, 2 and 8). What is the total number os possibilities to get to the total length ? So in this case, a 2, 2, 2, 2, 2,2 ,1 is different then 1, 2, 2, 2, 2, 2, 2.
– Felipe Ribeiro R. Magalhaes Aug 21 '16 at 21:22