RosettaCodeData/Task/Factorial/Python/factorial-4.py

9 lines
189 B
Python
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
from itertools import (accumulate, chain)
from operator import mul
# factorial :: Integer
2015-02-20 00:35:01 -05:00
def factorial(n):
2019-09-12 10:33:56 -07:00
return list(
accumulate(chain([1], range(1, 1 + n)), mul)
)[-1]