General FizzBuzz: Difference between revisions
Content deleted Content added
m →{{header|Python}}: Removed unnecessary import and empty line; changed order in example output. |
→{{header|Lua}}: Changed to reflect changes in the original (Python) version. |
||
Line 1,166:
'''One of the few solutions which do not use expensive modulo ''(think about the CPU!)''.'''
{{trans|Python}}
<lang Lua>local
local
3, 'sauce ',
}
local function fizzbuzz(n, mods)
n = n or
mods = #mods ~= 0 and mods or
local res = {}
for
for i = mod, n, mod do
res[i] = (res[i] or '') .. name
end
Line 1,196 ⟶ 1,198:
local n_mods = 0
while n_mods ~=
local line = io.read()
if not line then break end
Line 1,202 ⟶ 1,204:
local num = tonumber(line:sub(1, s-1))
local name = line:sub(e+1)
mods[
mods[#mods+1] = name
n_mods = n_mods + 1
end
|