This is what I have:
I am supposed to just compute for f. This defines too many values, it should just define for n >=1, so do I change my 2 to a 1? Not sure here. Thanks!!Code:
#include <iostream.h>
//f(1)=2, f(2)=2, f(n)=2*f(n-1) + f(n-2)
int f(int n)
{
if (n <= 2)
{
return 2;
}
return (2 * f(n - 1) + f(n - 2));
}
// This part was to test my code.
int main()
{
for ( int i = 0; i < 4; ++i )
{
std::cout << "f(" << i << ") = " << f(i) << std::endl;
}
return 0;
}