Solve problem 56 using Erlang.