Solve problem 47 using Lua.