Added Lua fizzbuzz example
[langlearn/.git] / fizzbuzz / lua / MaximumGeeker / fizzbuzz.lua
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