Do problem 17 in Erlang.