I am having trouble figuring out exactly how to code this modified Fibonacci sequence. I'm trying to practice using recursion even though it's probably not the best bet sometimes, but the point is I have to use the recursive method.
The rules of the sequence are as follows:
s(n+1) = {(1, if n = -1) or (the sum from i = 0 to n of 2^n * s(n) * s(n-1))}
I'm having trouble figuring out how to code this as it's defined in the term after the n I am using and I can't figure out how to sum it all up once i find an individual term. Honestly I wish it was better explained than just "code this".
Here's the code I have right now to try and solve it but it's not giving the right answer (obviously, since I can't figure out the algorithm).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
if (n == -1)
{
return 1;
}
elseif (n == 0)
{
return 1;
}
else
{
int f;
f = pow(2.0, n) * sequence(n - 1) * sequence(n - 2);
//I assume the summation line(s) will go here
return f;
}