Solve problem 120 using Erlang.