Erlang Code for mandatory question