write factorial function for problem 20