Step through a recursive call to factorial(N) in both C and JavaScript, frame by frame.
Both languages follow the same LIFO discipline; the per-frame cost differs because JavaScript carries
more context per call (environment record, closure, this) than a bare C activation record.
Controls
factorial(3)
Active frames: 0 / 3
C total:0 BJS total:0 BΔ (JS − C):0 B
C low-level activation record
int factorial(int n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
// main: factorial(3)
No active calls. Click "call" or "full recursion".
JavaScript ECMAScript execution context
function factorial(n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
// factorial(3)
No active calls. Click "call" or "full recursion".