n=1 r = 1 x = 2 |
int factr(int n) { if(n == 1) return 1; int r = factr(n-1); int x = n * r; return x; } // factr |
n=2 r = 1 x = 2 |
int factr(int n) { if(n == 1) return 1; int r = factr(n-1); int x = n * r; return x } // factr |
n=3 r = 2 x = 6 |
int factr(int n) { if(n == 1) return 1; int r = factr(n-1); int x = n * r; return x; } // factr |
argc=1 argv[0]="main" res = 6 |
int main(int argc, char * argv[]) { int res = factr(3); cout << "res = " << res << endl; return 0; } // main |