Solve problem 5 using Lua.