30 lines
694 B
Text
30 lines
694 B
Text
require "io2"
|
|
|
|
local n = io.readInt("Maximum number : ", 3)
|
|
local factors = {}
|
|
local words = {}
|
|
for i = 1, 3 do
|
|
while true do
|
|
local factor = io.readInt($"Factor {i} : ", 2)
|
|
if factor in factors then
|
|
print("Must be an unused integer > 1, try again.")
|
|
else
|
|
factors:insert(factor)
|
|
local word = io.readStr($" Word {i} : ", 1)
|
|
words[factor] = word
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
factors:sort()
|
|
print()
|
|
for i = 1, n do
|
|
local s = ""
|
|
for j = 1, 3 do
|
|
local factor = factors[j]
|
|
if i % factor == 0 then s ..= words[factor] end
|
|
end
|
|
if s == "" then s = tostring(i) end
|
|
print(s)
|
|
end
|