from functools import reduce prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
from itertools import productdef prod(n):if not n:return 0n = n[-1]fact = lambda x: x if x <= 2 else x*fact(x-1)return fact(n)- from functools import reduce
- prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
Algorithms
Logic