I have this which solves a problem iteratively using a for loop. I want to convert the code to use a recursive algorithm using if-else statement that uses recursion. I've tried several times but I can't get it to work properly.
double A;
int B;
double previous=1;
double answer;
double equation(double A,int B){
for(int i=1; i<=B; i++){
answer= (A*previous)/(i+A*previous);
previous = answer;
};
return answer;
}
EDIT: Here's what I've done so far: http://pastebin.com/raw.php?i=kyeq1v5u