I searched the forums but I didn't find any useful information. I am just trying to write a simple recursive solution to do F(n). It seems simple to me but I am probably not thinking about it correctly. My program has no errors, but it only returns 55 and then exits.
#include <iostream>
using namespace std;
int F(int);
int main()
{
int fibonacci_input;
cout << "Enter a positive integer to be Fibonacci'ed: ";
cin >> fibonacci_input;
cout << endl << F(fibonacci_input) << endl;
return 0;
} //end main
int F(int n)
{
if (n == 0)
return 0;
else if (n == 1)
return 1;
else
return F(n-1)+F(n-2);
} //end F()