okay this is the stuff that I came up with as far as code is concerned
Code:
#include <iostream>
int fibonacci(int a, int b, int c);
using namespace std;
int main()
{
int a, b, c;
char j='y';
while(j!='n')
{
cout<<"Enter the first number in the fibonacci sequence: "<<"\n";
cin>>a;
cout<<"Enter the second number in the fibonacci sequence: "<<"\n";
cin>>b;
cout<<"Enter what degree you'd like to go to: "<<"\n";
cin>>c;
cout<<"The fibonacci value calculated is: "<<c<<fibonacci(a,b,c)<<"\n";
cout<<"Would you like to continue Y/N"<<endl;
cin>>j;
}
return 0;
}
int fibonacci(int a, int b, int c)
{
if(c==1)
return a;
else if (c==2)
return b;
else
return fibonacci(a,b,c - 1) + fibonacci(a, b, c - 2);
}
I'm only having one issue it keeps giving me bogus output