EDIT
This question was originally asked in StackOverflow:
We know what it means in code but not in mathematics.
Yet, the following is my attempt to interpret it.
Although this has already been close, I hope someone can share light on it eventually.
Original question
I've got this function, but I can't figure out what does it describes.
The function:
f(n,x,y)
Returns the number for times the product of x times y is exactly n
What I can't figure out/understand is what are the "steps" ( the way n, x and y change )?
Here's a table
n=7 x=2 y=3 7 2 3 5 2 2 4 3 2 3 2 1 3 4 2 2 3 1 2 5 2 1 2 0 1 4 1 1 6 2 0 3 0 0 5 1 0 7 2
This function return 1, because only in n=0, x=3, y=0 the product of x times y is exactly the value of n
for f( n=8, x=2, y=3) the value is 2 ( when
n=0, x=4, y=0 and
n=3, x=3, y=1 )
f( n=9, x=2, y=3) the value is 3 ( when
n=0, x=5, y=0 ,
n=0, x=4, y=0 and
n=6, x=3, y=2 )
What does that function describe?
Here's the function in python
def somerec(n, x, y):
if n < x*y:
return 0
if n == x*y:
return 1
sum_ = 0
for i in range(x, n+1):
sum_ += somerec(n-i, i, y-1)
return sum_
And in Java:
public class SomeRec {
public static void main( String [] args ) {
int n = Integer.parseInt(args[0]);
int x = Integer.parseInt(args[1]);
int y = Integer.parseInt(args[2]);
System.out.println( somerec( n,x,y ));
}
public static int somerec( int n, int x, int y ) {
if (n < x*y){
return 0;
} else if (n == x*y) {
return 1;
} else {
int sum = 0;
for (int i=x; i<=n;i++) {
sum += somerec(n-i,i,y-1);
}
return sum;
}
}
}
Thanks for the help in advance, and I apologize for not using mathematical terms :-S

