lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Ok, call me stupid, but a recursive function in my book would be one
> that can call itself and is self-contained.
> 
> [...] this is _not_ a self-contained recursive function [...] to get a
> self-contained recursive function?

If a recursive function should be self contained, why do you need to
write "self-contained recursive function"? ;)

Anyway, I guess the _simplest_ way to get a *self-contained* recursive
function is this:

local function fact(n)
  if n>1 then
    return n*fact(n-1)
  end
  return 1
end

-- Roberto