reduce
suggest changeIn 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))
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents