Holy smokes Batman!!!
That worked. So when do u use something like n=2 vs n==2
also, when u use "return" it return the value to the calling function to use it again if the conditions are not met?
revised code.
Code:
#include<iostream>
using namespace std;
int computef(int n)
{
int answer;
if ((n==2)||(n==1))
return 2;
else
answer= 2*computef(n-1)+computef(n-2);
return answer;
cout << answer;
}
int main()
{
int x;
cout << "Please input the number for calculation " ;
cin >> x;
cout << computef(x);
system("pause");
return 0;
}