Quote:
|
Originally Posted by DaWei
Caveat: the recursive approach may use up your allotted stack before it uses up the memory you've alloted for the result. Most likely not for a factorial operation, though; the result grows rapidly, to indulge in an understatement.
|
Recursion on a predefined chunk of memory with passing just a pointer at a time is basically cost-less in terms of stack space.
But yes, it can be done at about the same complexity level by iterative means.