//* Recursive Fibonacci function *

// Warning: Recursive Fibonacci is an example // of very poor algorithm design as the same // data is calculated from the scratch many times #include <iostream> using namespace std; long FIB(int n); int main() { int num; cout << "Please enter the base and an integer exponent "; cin >> num; cout << num << "th Fibonacci number is " << FIB(num) << endl; return(0); } long FIB(int n) { if (n<0) return(0); // illegal argument if (n==0) return(0); if (n==1) return(1); return( FIB(n-1) + FIB(n-2) ); }