reduce

suggest change

In Python 3.x, the reduce function already explained here has been removed from the built-ins and must now be imported from functools.

from functools import reduce
def factorial(n):
    return reduce(lambda a, b: (a*b), range(1, n+1))

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents