Defined factorial function.