[issue2138] Add a factorial function

2008-05-31 Thread Joshua Uziel
Joshua Uziel <[EMAIL PROTECTED]> added the comment: Or slightly better: from operator import mul def factorial(num): return reduce(mul, range(2, num+1), 1) ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue2138] Add a factorial function

2008-05-31 Thread Joshua Uziel
Joshua Uziel <[EMAIL PROTECTED]> added the comment: It's a simplified version, but why not something like this: import operator def factorial(num): return reduce(operator.mul, range(1, num+1)) A product() function could also be done similarly. --