Solve problem 57 using Erlang.