Solve problem 145 using Erlang.