#include #include using namespace std; // vt100 codes to do some special drawing characters // DO NOT DO THIS ON A PROJECT - if (terminal != vt100) { UGLY } const string ESC = string(1, char(27)); const string STR1 = ESC + "(0tqqq" + ESC + "(B"; const string STR2 = ESC + "(0mqqq" + ESC + "(B"; const string STR3 = ESC + "(0x" + ESC + "(B "; const string STR4 = " "; // probably a better way to do this but it is eluding me at the moment int Fibonacci(int x, string now, string future) { cout << now << "Fibonacci(" << x << ") " << endl; if(x==1 || x==2) { return 1; } else { return Fibonacci(x-1, future + STR1, future + STR3) + Fibonacci(x-2, future + STR2, future + STR4); } } int main (int argc, char** argv) { if(argc!=2) { cerr << "Usage: " << argv[0] << " n" << endl; exit(EXIT_FAILURE); } int x = atoi(argv[1]); cout << endl << "Result: Fibonacci(" << x << "): " << Fibonacci(x,"","") << endl; return EXIT_SUCCESS; }