Of course, in Python, we could use math.prod and range for an even more readable version:
from math import prod
def factorial(n):
return prod(range(1, n+1))
Though, the BEST approach is to just use math.factorial:
from math import factorial
🧵 (3/6)