Skip to content

Instantly share code, notes, and snippets.

@preprocessor
Last active December 25, 2015 02:58
Show Gist options
  • Save preprocessor/6905991 to your computer and use it in GitHub Desktop.
Save preprocessor/6905991 to your computer and use it in GitHub Desktop.
Tail recursion in lua
function countdwn(n)
while n>0 do
print(n)
countdwn(n-1)
else
print("0")
end
end
--[[
Usage: countdwn(natural number)
> countdwn(10)
10
9
8
7
6
5
4
3
2
1
0
>
--]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment