Im trying to calculate N Choose R by multiplication but it returns some crazy value like -1#inde. Its for a prac. I have already done it iteratively and recursively, and need to do it by multiplication.

The formula we were given was:

N Choose R = (n / r) * ( (n - 1) / (n - 2) ) * ... ((n - r + 1) / 1).

The code I have now is:

Any suggestions?Code:

/*************************************

CALCULATE N CHOOSE R BY MULTIPLICATION

*************************************/

float MultiplicationFactorial(float n, float r)

{

float i = 0;

float output = 0;

if(r == 0)

{

output = 1;

return output;

}

else

{

for(i = 0; (r - i) == 1; i++)

{

output = (output * (( n + i) / (r + i)));

return output;

}

}

}

the variables that im passing to the function are all floats. If I put n = 4 and r = 2, then it should return 6.

Any help appreciated.

.ZG.