Implementing factorial program in erlang