Solve problem 44 using Erlang.