Thread: 500!
View Single Post
Old Jun 24th, 2005, 10:49 AM   #5
Aphex_Twin
Newbie
 
Join Date: Mar 2005
Posts: 27
Rep Power: 0 Aphex_Twin is on a distinguished road
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.
Aphex_Twin is offline   Reply With Quote