The problem is from SPOJ Online Judge [problem description]
This problem is for beginner, and we use this to continue practise our LUA skills.
-- split a string into array
function split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
s = split(io.read(), [[ ]])
a = tonumber(s[1])
b = tonumber(s[2])
s = 0
for i = a, b do
s = s + i * i
end
print(s)
The solution is to implement a loop to sum the squares of each number given a range.
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Coding Exercise - SPOJ - 1417. University Employees - LUA programming
Next Post: Coding Exercise - LUA Programming - SPOJ Online Judge - 15711. Wow