Added Lua fizzbuzz example
authorNo-one-you-know <nooneyouknow@dismail.de>
Fri, 19 Feb 2021 05:14:37 +0000 (05:14 +0000)
committerNo-one-you-know <nooneyouknow@dismail.de>
Fri, 19 Feb 2021 05:14:37 +0000 (05:14 +0000)
fizzbuzz/lua/MaximumGeeker/fizzbuzz.lua [new file with mode: 0644]

diff --git a/fizzbuzz/lua/MaximumGeeker/fizzbuzz.lua b/fizzbuzz/lua/MaximumGeeker/fizzbuzz.lua
new file mode 100644 (file)
index 0000000..a4c6a65
--- /dev/null
@@ -0,0 +1,23 @@
+--[[ FizzBuzz, Lua 5.1 ]]--
+
+local ans = {
+  'Fizz',
+  'Buzz',
+  'FizzBuzz'
+}
+
+for i = 1, 100 do
+  local c = 0
+
+  if i%3 == 0 then
+    c = c + 1
+  end
+
+  if i%5 == 0 then
+    c = c + 2
+  end
+
+  if ans[c] then
+    print( i, ans[c] )
+  end
+end