Iteration vs Recursion
Most problems that can be solved with iteration (
for,
while,
do
loops) can
also be solved with recursion. Pros and cons are:
- Iteration code will be faster and will use less resources.
- Recursion normaly looks more like the original formula.
Anyway up, as an example of both technics here is some code to give the
factorial of a number.
Iteration------
Recursion
Martin Leslie