On Thu, 7 Nov 2002, Mirian Crzig Lennox wrote:

> 	  def factorial x
> 	    fail if x < 1
> 	    (x == 1) ? x : x * factorial(x - 1)
> 	  end
>
> Am I going to get at most one stack frame or zillions?

Zillions, since your function isn't tail recursive:

 def fact-iter x, acc
   fact-iter x-1, x * acc
 end

 def fact x
   fact-itern x, 1
 end

But even this gives you the zillion frames, since ruby doesn't handle tail
recursion yet: from what I recall an experimental version exists.

  -- Nikodemus