implementing factorial function two different ways