Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/FizzBuzz/Lua/fizzbuzz-1.lua
Normal file
11
Task/FizzBuzz/Lua/fizzbuzz-1.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
for i = 1, 100 do
|
||||
if i % 15 == 0 then
|
||||
print("FizzBuzz")
|
||||
elseif i % 3 == 0 then
|
||||
print("Fizz")
|
||||
elseif i % 5 == 0 then
|
||||
print("Buzz")
|
||||
else
|
||||
print(i)
|
||||
end
|
||||
end
|
||||
13
Task/FizzBuzz/Lua/fizzbuzz-2.lua
Normal file
13
Task/FizzBuzz/Lua/fizzbuzz-2.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
for i = 1, 100 do
|
||||
output = ""
|
||||
if i % 3 == 0 then
|
||||
output = output.."Fizz"
|
||||
end
|
||||
if i % 5 == 0 then
|
||||
output = output.."Buzz"
|
||||
end
|
||||
if(output == "") then
|
||||
output = i
|
||||
end
|
||||
print(output)
|
||||
end
|
||||
5
Task/FizzBuzz/Lua/fizzbuzz-3.lua
Normal file
5
Task/FizzBuzz/Lua/fizzbuzz-3.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
word = {"Fizz", "Buzz", "FizzBuzz"}
|
||||
|
||||
for i = 1, 100 do
|
||||
print(word[(i % 3 == 0 and 1 or 0) + (i % 5 == 0 and 2 or 0)] or i)
|
||||
end
|
||||
13
Task/FizzBuzz/Lua/fizzbuzz-4.lua
Normal file
13
Task/FizzBuzz/Lua/fizzbuzz-4.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
local t = {
|
||||
[0] = "FizzBuzz",
|
||||
[3] = "Fizz",
|
||||
[5] = "Buzz",
|
||||
[6] = "Fizz",
|
||||
[9] = "Fizz",
|
||||
[10] = "Buzz",
|
||||
[12] = "Fizz"
|
||||
}
|
||||
|
||||
for i = 1, 100 do
|
||||
print(t[i%15] or i)
|
||||
end
|
||||
20
Task/FizzBuzz/Lua/fizzbuzz-5.lua
Normal file
20
Task/FizzBuzz/Lua/fizzbuzz-5.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env luajit
|
||||
local to=arg[1] or tonumber(arg[1]) or 100
|
||||
local CF,CB=3,5
|
||||
local cf,cb=CF,CB
|
||||
for i=1,to do
|
||||
cf,cb=cf-1,cb-1
|
||||
if cf~=0 and cb~=0 then
|
||||
io.write(i)
|
||||
else
|
||||
if cf==0 then
|
||||
cf=CF
|
||||
io.write("Fizz")
|
||||
end
|
||||
if cb==0 then
|
||||
cb=CB
|
||||
io.write("Buzz")
|
||||
end
|
||||
end
|
||||
io.write(", ")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue