Tail Recursion
fac(n) = f
1
(1, n, 1);
fac(n) = n <= 1 ? 1 : n*fac(n-1);
f
1
(a, n, x) = x <= n ?
f
1
(a*x, n, x+1)
: a;
tail-recursive
non-tail-recursive
There is no Òmessy cleanupÓ after the inner function is called.
Good Housekeeping
Seal of Approval