Solve problem 42 using Erlang.