Writing factorial functions in python:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def factorial_simple(n): if n == 0: return 1 else: return n * factorial_simple(n - 1) print(factorial_simple(5)) def factorial(n): return reduce(lambda x,y:x*y, [1]+range(1,n+1)) print(factorial(5)) |