Recursion

Recursion is any solution technique in which large problems
are solved by reducing them to smaller problems of the same form.

According to multiple sources, the text Thinking Recursively
by Eric Roberts (John Wiley 1986) is an excellent resource on recursion.

Internally, recursive functions are supported using a stack.

Almost every recursive function has the same basic structure:

if (test for simple case)
return (simple solution computed w/o using recursion)
else
return (recursive solution involving a call to the same function)

A recursive function is a function that calls itself in
its function body. The call uses different arguments that ultimately
read values that allow the function to return a result.

A recursive algorithm must have a well-defined stopping state, or
termination condition.

Tail recursion is when the only recursive call appears in the
function and that recursive call is the last operation performed at
that procedural level. Typically, tail recursive functions can be
easily rewritten as non-recursive functions. The
traverse linked-list example provides an example of tail
recursion.

Some final comments:

Recursion replaces the loop.

Recursion may provide no saving in storage, since somewhere a stack
of the values being processed must be maintained.

Recursion will not be faster.

Recursive code is more compact, and often much easier to
write and understand than the non-recursive equivalent.

> Microsoft seem to have confused addition with multiplication.
> Such an easy mistake to make.

Followup postings pin down the likely source of the bug as
incorrectly handled tail recursion in Microsoft's JIT compiler.
Unfortunately there seems to be no way to turn off JIT.
Kennedy speculates that this error may be responsible for the
failure of a large number of Java applets to run in the IE 4 environment.