-- Homework 18, challenge -- solution.

io.write("Enter a positive whole number n: ")
local n = tonumber(io.read())

local total = 0
for i = 1, n do
    total = total + i
end

print("Sum from 1 to " .. n .. " is " .. total)
print("Formula gives " .. (n * (n + 1) / 2))
