added factorial function

recursively computes the factorial of a number