Solve problem 34 using Erlang.