#include using namespace std; // global - yuk! int indenting = 0; int factorial(int x) { indenting++; for(int i = 0; i < indenting - 1; i++ ) { cout << " "; } // base case if(x==0) { cout << "1" << endl; indenting--; return 1; // recurrence case } else { cout << x << " * factorial(" << x - 1 << ")" << endl; int result = factorial(x-1); indenting--; return x * result; } } 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 << "factorial(" << x << "): " << factorial(x) << endl; return EXIT_FAILURE; }