RosettaCodeData/Task/Factorial/Lua/factorial-3.lua
2023-07-01 13:44:08 -04:00

7 lines
157 B
Lua

fact = setmetatable({[0] = 1}, {
__call = function(t,n)
if n < 0 then return 0 end
if not t[n] then t[n] = n * t(n-1) end
return t[n]
end
})