Python function for factorial using reduce


Topic: Python function for factorial using reduce

Solution

def fact(n):
    from operator import mul
    from functools import reduce
    return reduce(mul, range(1, n+1))
fact(10)



List all Python Programs