Here\'s my approach to factorials:
def factorial(n): \'\'\'Returns factorial of n\'\'\' r = 1 for i in range(1, n + 1): r *= i return
If you need a short execution time and don't need the best possible accuracy, you can use an approximation formula, e.g. Stirling approximation