Skip to content

Instantly share code, notes, and snippets.

@ponzao
Created March 26, 2010 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponzao/344894 to your computer and use it in GitHub Desktop.
Save ponzao/344894 to your computer and use it in GitHub Desktop.
factorial = { 1 }
setmetatable(factorial, { __index = function(table, key)
table[key] = table[key - 1] * key
return table[key]
end, __call = function(table, n)
for i = 1, n do
print(table[i])
end
end })
factorial(arg[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment