summaryrefslogtreecommitdiffstats
path: root/AppPkg/Applications/Lua/scripts/Fact.lua
diff options
context:
space:
mode:
Diffstat (limited to 'AppPkg/Applications/Lua/scripts/Fact.lua')
-rw-r--r--AppPkg/Applications/Lua/scripts/Fact.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/AppPkg/Applications/Lua/scripts/Fact.lua b/AppPkg/Applications/Lua/scripts/Fact.lua
new file mode 100644
index 0000000000..b935c7a04f
--- /dev/null
+++ b/AppPkg/Applications/Lua/scripts/Fact.lua
@@ -0,0 +1,12 @@
+-- defines a factorial function
+function fact (n)
+ if n == 0 then
+ return 1
+ else
+ return n * fact(n-1)
+ end
+end
+
+print("enter a number:")
+a = io.read("*number") -- read a number
+print(fact(a))