Solve problem 43 using Erlang.