Join Nostr
2026-05-10 17:46:01 UTC
in reply to

Trey Hunner 🐍 on Nostr: Of course, in Python, we could use math.‍prod and range for an even more readable ...

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)