in reply to Re: Re: Recursive to Iterative using Closures (Fun with Fibonacci)
in thread Recursive to Iterative using Closures (Fun with Fibonacci)

Recursion is suitable for problems where you can divide the problem into one or more independent subsets; you can solve the problem for the subsets and use the results to efficient calculate the result for the entire set; and each of the subsets should be significantly smaller than the original set.

A recursive solution for Fibonacci fails the first requirement, the "sets" are not independent (it also fails the third requirement). Calculating the factorial is also a common example for recursion, but that fails the the third requirement, making that the overhead of calling subs is significant, and it's not compensated by simpler code. Recursion can't really beat:

my $p = 1; $p *= $_ for 2 .. $n;

Abigail