#include <iostream>
using namespace std;
int fib(int n);
int main()
{
int n, answer;
cout << "Enter number to find: ";
cin >> n;
cout << "\n\n";
answer = fib(n);
cout << answer << " is the " << n << "th Fibonacci number\n";
system("PAUSE");
return 0;
}
int fib (int n)
{
cout << "Processing fib(" << n << ")... ";
if (n < 3 )
{
cout << "Return 1!\n";
return (1);
}
else
{
cout << "Call fib(" << n-2 << ") and fib(" << n-1 << ").\n";
return( fib(n-2) + fib(n-1));
}
}
can i get this to print
fibonacci(1) = 1
fibonacci(2) = 1
fibonacci(3) = 6
all the way until i get the integer i entered
for example, if i would input 5, it would say
fibonacci(1) = 1
fibonacci(2) = 1
fibonacci(3) = 6
fibonacci(4) = 24
fibonacci(5) = 120